Class: Galago::Router::Route
- Inherits:
-
Object
- Object
- Galago::Router::Route
- Defined in:
- lib/galago/router/route.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add_endpoint(request_method, endpoint) ⇒ Object
- #allowed_methods ⇒ Object
- #call(env) ⇒ Object
-
#initialize(path) ⇒ Route
constructor
A new instance of Route.
- #recognizes_path?(request_path) ⇒ Boolean
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/galago/router/route.rb', line 5 def path @path end |
Instance Method Details
#add_endpoint(request_method, endpoint) ⇒ Object
12 13 14 |
# File 'lib/galago/router/route.rb', line 12 def add_endpoint(request_method, endpoint) @endpoints[request_method] = endpoint end |
#allowed_methods ⇒ Object
16 17 18 |
# File 'lib/galago/router/route.rb', line 16 def allowed_methods @endpoints.keys.sort end |
#call(env) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/galago/router/route.rb', line 24 def call(env) env['galago_router.path'] = @path.to_s env['galago_router.params'] = @path.params_from(env) endpoint = @endpoints.fetch(env['REQUEST_METHOD'], method_not_allowed) endpoint.call(env) end |
#recognizes_path?(request_path) ⇒ Boolean
20 21 22 |
# File 'lib/galago/router/route.rb', line 20 def recognizes_path?(request_path) @path.recognizes?(request_path) end |