Class: Grape::Router::Route
- Extended by:
- Forwardable
- Defined in:
- lib/grape/router/route.rb
Constant Summary collapse
- FORWARD_MATCH_METHOD =
->(input, pattern) { input.start_with?(pattern.origin) }
- NON_FORWARD_MATCH_METHOD =
->(input, pattern) { pattern.match?(input) }
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
Attributes inherited from BaseRoute
Instance Method Summary collapse
- #apply(app) ⇒ Object
- #convert_to_head_request! ⇒ Object
-
#initialize(endpoint, method, pattern, options) ⇒ Route
constructor
A new instance of Route.
- #match?(input) ⇒ Boolean
- #params(input = nil) ⇒ Object
Methods inherited from BaseRoute
#namespace, #pattern_regexp, #regexp_capture_index, #to_regexp
Constructor Details
#initialize(endpoint, method, pattern, options) ⇒ Route
Returns a new instance of Route.
15 16 17 18 19 20 |
# File 'lib/grape/router/route.rb', line 15 def initialize(endpoint, method, pattern, ) super(pattern, ) @app = endpoint @request_method = upcase_method(method) @match_function = [:forward_match] ? FORWARD_MATCH_METHOD : NON_FORWARD_MATCH_METHOD end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
11 12 13 |
# File 'lib/grape/router/route.rb', line 11 def app @app end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
11 12 13 |
# File 'lib/grape/router/route.rb', line 11 def index @index end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
11 12 13 |
# File 'lib/grape/router/route.rb', line 11 def request_method @request_method end |
Instance Method Details
#apply(app) ⇒ Object
26 27 28 29 |
# File 'lib/grape/router/route.rb', line 26 def apply(app) @app = app self end |
#convert_to_head_request! ⇒ Object
22 23 24 |
# File 'lib/grape/router/route.rb', line 22 def convert_to_head_request! @request_method = Rack::HEAD end |
#match?(input) ⇒ Boolean
31 32 33 34 35 |
# File 'lib/grape/router/route.rb', line 31 def match?(input) return false if input.blank? @match_function.call(input, pattern) end |
#params(input = nil) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/grape/router/route.rb', line 37 def params(input = nil) return params_without_input if input.blank? parsed = pattern.params(input) return unless parsed parsed.compact.symbolize_keys end |