diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-26 13:28:06 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-26 13:28:06 -0600 |
commit | feb7382047bf5e354edd12aa89895ec4591a5614 (patch) | |
tree | 21828f6fa5857d09a761b9a5e5b8b3c6c20cdc51 /actionpack/lib/action_dispatch | |
parent | 673fa7f06608151aa4a5e6e754894978b4000b63 (diff) | |
download | rails-feb7382047bf5e354edd12aa89895ec4591a5614.tar.gz rails-feb7382047bf5e354edd12aa89895ec4591a5614.tar.bz2 rails-feb7382047bf5e354edd12aa89895ec4591a5614.zip |
AD::Cascade that supports X-Cascade
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cascade.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cascade.rb b/actionpack/lib/action_dispatch/middleware/cascade.rb new file mode 100644 index 0000000000..9f5c9891f0 --- /dev/null +++ b/actionpack/lib/action_dispatch/middleware/cascade.rb @@ -0,0 +1,29 @@ +module ActionDispatch + class Cascade + def self.new(*apps) + apps = apps.flatten + + case apps.length + when 0 + raise ArgumentError, "app is required" + when 1 + apps.first + else + super(apps) + end + end + + def initialize(apps) + @apps = apps + end + + def call(env) + result = nil + @apps.each do |app| + result = app.call(env) + break unless result[1]["X-Cascade"] == "pass" + end + result + end + end +end |