Class: Deas::Route
- Inherits:
-
Object
- Object
- Deas::Route
- Defined in:
- lib/deas/route.rb
Instance Attribute Summary collapse
-
#handler_class ⇒ Object
readonly
Returns the value of attribute handler_class.
-
#handler_proxy ⇒ Object
readonly
Returns the value of attribute handler_proxy.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(method, path, handler_proxy) ⇒ Route
constructor
A new instance of Route.
-
#run(sinatra_call) ⇒ Object
TODO: unit test this??.
- #validate! ⇒ Object
Constructor Details
#initialize(method, path, handler_proxy) ⇒ Route
Returns a new instance of Route.
8 9 10 |
# File 'lib/deas/route.rb', line 8 def initialize(method, path, handler_proxy) @method, @path, @handler_proxy = method, path, handler_proxy end |
Instance Attribute Details
#handler_class ⇒ Object (readonly)
Returns the value of attribute handler_class.
6 7 8 |
# File 'lib/deas/route.rb', line 6 def handler_class @handler_class end |
#handler_proxy ⇒ Object (readonly)
Returns the value of attribute handler_proxy.
6 7 8 |
# File 'lib/deas/route.rb', line 6 def handler_proxy @handler_proxy end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/deas/route.rb', line 6 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/deas/route.rb', line 6 def path @path end |
Instance Method Details
#run(sinatra_call) ⇒ Object
TODO: unit test this??
17 18 19 20 21 22 23 24 25 |
# File 'lib/deas/route.rb', line 17 def run(sinatra_call) sinatra_call.request.env.tap do |env| env['sinatra.params'] = sinatra_call.params env['deas.handler_class_name'] = self.handler_class.name env['deas.logging'].call " Handler: #{env['deas.handler_class_name']}" env['deas.logging'].call " Params: #{env['sinatra.params'].inspect}" end Deas::SinatraRunner.run(self.handler_class, sinatra_call) end |
#validate! ⇒ Object
12 13 14 |
# File 'lib/deas/route.rb', line 12 def validate! @handler_class = @handler_proxy.handler_class end |