Class: Grape::Router::BaseRoute
- Inherits:
-
Object
- Object
- Grape::Router::BaseRoute
- Defined in:
- lib/grape/router/base_route.rb
Direct Known Subclasses
Defined Under Namespace
Classes: CaptureIndexCache
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#options ⇒ Object
(also: #attributes)
readonly
Returns the value of attribute options.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(**options) ⇒ BaseRoute
constructor
A new instance of BaseRoute.
- #pattern_regexp ⇒ Object
- #regexp_capture_index ⇒ Object
- #to_regexp(index) ⇒ Object
Constructor Details
#initialize(**options) ⇒ BaseRoute
Returns a new instance of BaseRoute.
10 11 12 |
# File 'lib/grape/router/base_route.rb', line 10 def initialize(**) @options = ActiveSupport::OrderedOptions.new.update() end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
8 9 10 |
# File 'lib/grape/router/base_route.rb', line 8 def index @index end |
#options ⇒ Object (readonly) Also known as: attributes
Returns the value of attribute options.
8 9 10 |
# File 'lib/grape/router/base_route.rb', line 8 def @options end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
8 9 10 |
# File 'lib/grape/router/base_route.rb', line 8 def pattern @pattern end |
Instance Method Details
#pattern_regexp ⇒ Object
20 21 22 |
# File 'lib/grape/router/base_route.rb', line 20 def pattern_regexp pattern.to_regexp end |
#regexp_capture_index ⇒ Object
16 17 18 |
# File 'lib/grape/router/base_route.rb', line 16 def regexp_capture_index CaptureIndexCache[index] end |
#to_regexp(index) ⇒ Object
24 25 26 27 |
# File 'lib/grape/router/base_route.rb', line 24 def to_regexp(index) @index = index Regexp.new("(?<#{regexp_capture_index}>#{pattern_regexp})") end |