class Rack::ExpectationCascade
Constants
- ContinueExpectation
- Expect
- ExpectationFailed
- NotFound
Attributes
apps[R]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/rack/contrib/expectation_cascade.rb 13 def initialize 14 @apps = [] 15 yield self if block_given? 16 end
Public Instance Methods
<<(app)
click to toggle source
# File lib/rack/contrib/expectation_cascade.rb 30 def <<(app) 31 @apps << app 32 end
call(env)
click to toggle source
# File lib/rack/contrib/expectation_cascade.rb 18 def call(env) 19 set_expectation = env[Expect] != ContinueExpectation 20 env[Expect] = ContinueExpectation if set_expectation 21 @apps.each do |app| 22 result = app.call(env) 23 return result unless result[0].to_i == 417 24 end 25 set_expectation ? NotFound : ExpectationFailed 26 ensure 27 env.delete(Expect) if set_expectation 28 end