Class: Moon::Application::Rack::Route
- Inherits:
-
Object
- Object
- Moon::Application::Rack::Route
- Defined in:
- lib/moon/application/rack.rb
Overview
Abstraction for a application route
Instance Attribute Summary collapse
-
#rack_response ⇒ Object
readonly
Returns the value of attribute rack_response.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #actions ⇒ Object
- #define ⇒ Object
- #handle(session, params) ⇒ Object
- #http_method ⇒ Object
-
#initialize(application, transponder, route) ⇒ Route
constructor
A new instance of Route.
- #path ⇒ Object
Constructor Details
#initialize(application, transponder, route) ⇒ Route
Returns a new instance of Route.
59 60 61 62 |
# File 'lib/moon/application/rack.rb', line 59 def initialize(application, transponder, route) @application, @transponder, @route = application, transponder, route @environment = @transponder.environment end |
Instance Attribute Details
#rack_response ⇒ Object (readonly)
Returns the value of attribute rack_response.
57 58 59 |
# File 'lib/moon/application/rack.rb', line 57 def rack_response @rack_response end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
56 57 58 |
# File 'lib/moon/application/rack.rb', line 56 def response @response end |
Instance Method Details
#actions ⇒ Object
72 73 74 75 |
# File 'lib/moon/application/rack.rb', line 72 def actions actions = @route[:actions] actions.is_a?(Array) ? actions : [ actions ].compact end |
#define ⇒ Object
77 78 79 80 81 82 |
# File 'lib/moon/application/rack.rb', line 77 def define route = self @transponder.send http_method, path do route.handle session, params end end |
#handle(session, params) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/moon/application/rack.rb', line 84 def handle(session, params) build_context session, params perform_actions build_rack_response @rack_response end |
#http_method ⇒ Object
64 65 66 |
# File 'lib/moon/application/rack.rb', line 64 def http_method @route[:http_method] end |
#path ⇒ Object
68 69 70 |
# File 'lib/moon/application/rack.rb', line 68 def path @route[:path] end |