Class: Deas::HandlerProxy
- Inherits:
-
Object
- Object
- Deas::HandlerProxy
- Defined in:
- lib/deas/handler_proxy.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#handler_class ⇒ Object
readonly
Returns the value of attribute handler_class.
-
#handler_class_name ⇒ Object
readonly
Returns the value of attribute handler_class_name.
Instance Method Summary collapse
-
#initialize(handler_class_name) ⇒ HandlerProxy
constructor
A new instance of HandlerProxy.
- #run(server_data, sinatra_call) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(handler_class_name) ⇒ HandlerProxy
Returns a new instance of HandlerProxy.
10 11 12 |
# File 'lib/deas/handler_proxy.rb', line 10 def initialize(handler_class_name) @handler_class_name = handler_class_name end |
Instance Attribute Details
#handler_class ⇒ Object (readonly)
Returns the value of attribute handler_class.
8 9 10 |
# File 'lib/deas/handler_proxy.rb', line 8 def handler_class @handler_class end |
#handler_class_name ⇒ Object (readonly)
Returns the value of attribute handler_class_name.
8 9 10 |
# File 'lib/deas/handler_proxy.rb', line 8 def handler_class_name @handler_class_name end |
Instance Method Details
#run(server_data, sinatra_call) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/deas/handler_proxy.rb', line 18 def run(server_data, sinatra_call) # these are not part of Deas' intended behavior and route matching # they are side-effects of using Sinatra. remove them so they won't # be relied upon in Deas apps. sinatra_call.params.delete(:splat) sinatra_call.params.delete('splat') sinatra_call.params.delete(:captures) sinatra_call.params.delete('captures') runner = DeasRunner.new(self.handler_class, { :logger => server_data.logger, :router => server_data.router, :template_source => server_data.template_source, :request => sinatra_call.request, :session => sinatra_call.session, :params => sinatra_call.params }) runner.request.env.tap do |env| # make runner data available to Rack (ie middlewares) # this is specifically needed by the Logging middleware # this is also needed by the Sinatra error handlers so they can provide # error context. This may change when we eventually remove Sinatra. env['deas.handler_class'] = self.handler_class env['deas.handler'] = runner.handler env['deas.params'] = runner.params # this handles the verbose logging (it is a no-op if summary logging) env['deas.logging'].call " Handler: #{self.handler_class.name}" env['deas.logging'].call " Params: #{runner.params.inspect}" end runner.run end |
#validate! ⇒ Object
14 15 16 |
# File 'lib/deas/handler_proxy.rb', line 14 def validate! raise NotImplementedError end |