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_class_name ⇒ Object
readonly
Returns the value of attribute handler_class_name.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #constantize! ⇒ Object
-
#initialize(method, path, handler_class_name, handler_class = nil) ⇒ Route
constructor
A new instance of Route.
- #run(sinatra_call) ⇒ Object
Constructor Details
#initialize(method, path, handler_class_name, handler_class = nil) ⇒ Route
Returns a new instance of Route.
8 9 10 11 12 13 |
# File 'lib/deas/route.rb', line 8 def initialize(method, path, handler_class_name, handler_class = nil) @method = method @path = path @handler_class_name = handler_class_name @handler_class = handler_class 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_class_name ⇒ Object (readonly)
Returns the value of attribute handler_class_name.
6 7 8 |
# File 'lib/deas/route.rb', line 6 def handler_class_name @handler_class_name 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
#constantize! ⇒ Object
15 16 17 18 |
# File 'lib/deas/route.rb', line 15 def constantize! @handler_class ||= constantize_name(handler_class_name) raise(NoHandlerClassError.new(handler_class_name)) if !@handler_class end |
#run(sinatra_call) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/deas/route.rb', line 20 def run(sinatra_call) sinatra_call.request.env.tap do |env| env['sinatra.params'] = sinatra_call.params env['deas.handler_class_name'] = @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(@handler_class, sinatra_call) end |