Class: Rack::Chain
- Inherits:
-
Object
- Object
- Rack::Chain
- Defined in:
- lib/rack-chain/version.rb,
lib/rack/chain.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#filters ⇒ Object
Returns the value of attribute filters.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(endpoint, filters = []) ⇒ Chain
constructor
A new instance of Chain.
Constructor Details
#initialize(endpoint, filters = []) ⇒ Chain
Returns a new instance of Chain.
20 21 22 23 |
# File 'lib/rack/chain.rb', line 20 def initialize(endpoint, filters = []) @endpoint = endpoint @filters = filters end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/rack/chain.rb', line 5 def endpoint @endpoint end |
#filters ⇒ Object
Returns the value of attribute filters.
6 7 8 |
# File 'lib/rack/chain.rb', line 6 def filters @filters end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/rack/chain.rb', line 25 def call(env) Link.new(filters.reverse.inject(endpoint) do |endpt,filter| if filter.respond_to?(:[]) filter[Link.new(endpt)] else filter.new(Link.new(endpt)) end end).call(env) end |