Class: Rack::Tracker::HandlerSet
- Inherits:
-
Object
- Object
- Rack::Tracker::HandlerSet
- Defined in:
- lib/rack/tracker.rb
Defined Under Namespace
Classes: Handler
Instance Method Summary collapse
- #each(env = {}, &block) ⇒ Object
-
#handler(name, configuration = {}, &block) ⇒ Object
setup the handler class with configuration options and make it ready for receiving the env during injection.
-
#initialize(&block) ⇒ HandlerSet
constructor
A new instance of HandlerSet.
Constructor Details
#initialize(&block) ⇒ HandlerSet
Returns a new instance of HandlerSet.
82 83 84 85 |
# File 'lib/rack/tracker.rb', line 82 def initialize(&block) @handlers = [] instance_exec(&block) if block_given? end |
Instance Method Details
#each(env = {}, &block) ⇒ Object
102 103 104 |
# File 'lib/rack/tracker.rb', line 102 def each(env = {}, &block) @handlers.map { |h| h.init(env) }.each(&block) end |
#handler(name, configuration = {}, &block) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/rack/tracker.rb', line 95 def handler(name, configuration = {}, &block) # we need here "something" (which is atm the handler struct) # to postpone the initialization of the handler, # to give it the env and configuration options when the result of the handler is injected into the response. @handlers << Handler.new(Rack::Tracker::HandlerDelegator.handler(name), configuration) end |