Class: Grape::Router::Route
- Extended by:
- Forwardable
- Defined in:
- lib/grape/router/route.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
Attributes inherited from BaseRoute
Instance Method Summary collapse
- #apply(app) ⇒ Object
- #exec(env) ⇒ Object
-
#initialize(method, pattern, **options) ⇒ Route
constructor
A new instance of Route.
- #match?(input) ⇒ Boolean
- #params(input = nil) ⇒ Object
Methods inherited from BaseRoute
#pattern_regexp, #regexp_capture_index, #to_regexp
Constructor Details
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
8 9 10 |
# File 'lib/grape/router/route.rb', line 8 def app @app end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
8 9 10 |
# File 'lib/grape/router/route.rb', line 8 def request_method @request_method end |
Instance Method Details
#apply(app) ⇒ Object
22 23 24 25 |
# File 'lib/grape/router/route.rb', line 22 def apply(app) @app = app self end |
#exec(env) ⇒ Object
18 19 20 |
# File 'lib/grape/router/route.rb', line 18 def exec(env) @app.call(env) end |
#match?(input) ⇒ Boolean
27 28 29 30 31 |
# File 'lib/grape/router/route.rb', line 27 def match?(input) return false if input.blank? [:forward_match] ? input.start_with?(pattern.origin) : pattern.match?(input) end |
#params(input = nil) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/grape/router/route.rb', line 33 def params(input = nil) return params_without_input if input.blank? parsed = pattern.params(input) return {} unless parsed parsed.compact.symbolize_keys end |