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.
9 10 11 |
# File 'lib/deas/route.rb', line 9 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.
7 8 9 |
# File 'lib/deas/route.rb', line 7 def handler_class @handler_class end |
#handler_proxy ⇒ Object (readonly)
Returns the value of attribute handler_proxy.
7 8 9 |
# File 'lib/deas/route.rb', line 7 def handler_proxy @handler_proxy end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/deas/route.rb', line 7 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/deas/route.rb', line 7 def path @path end |
Instance Method Details
#run(sinatra_call) ⇒ Object
TODO: unit test this??
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/deas/route.rb', line 18 def run(sinatra_call) runner = Deas::SinatraRunner.new(self.handler_class, sinatra_call) sinatra_call.request.env.tap do |env| env['deas.params'] = runner.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['deas.params'].inspect}" end runner.run end |
#validate! ⇒ Object
13 14 15 |
# File 'lib/deas/route.rb', line 13 def validate! @handler_class = @handler_proxy.handler_class end |