Class: Grape::Router::BaseRoute
- Inherits:
-
Object
- Object
- Grape::Router::BaseRoute
- Extended by:
- Forwardable
- Defined in:
- lib/grape/router/base_route.rb
Direct Known Subclasses
Defined Under Namespace
Classes: CaptureIndexCache
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern, options = {}) ⇒ BaseRoute
constructor
A new instance of BaseRoute.
- #namespace ⇒ Object
- #pattern_regexp ⇒ Object
- #regexp_capture_index ⇒ Object
- #to_regexp(index) ⇒ Object
Constructor Details
#initialize(pattern, options = {}) ⇒ BaseRoute
Returns a new instance of BaseRoute.
15 16 17 18 |
# File 'lib/grape/router/base_route.rb', line 15 def initialize(pattern, = {}) @pattern = pattern @options = .is_a?(ActiveSupport::OrderedOptions) ? : ActiveSupport::OrderedOptions.new.update() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/grape/router/base_route.rb', line 10 def @options end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
10 11 12 |
# File 'lib/grape/router/base_route.rb', line 10 def pattern @pattern end |
Instance Method Details
#namespace ⇒ Object
21 22 23 |
# File 'lib/grape/router/base_route.rb', line 21 def namespace @namespace ||= @options[:namespace] end |
#pattern_regexp ⇒ Object
29 30 31 |
# File 'lib/grape/router/base_route.rb', line 29 def pattern_regexp @pattern.to_regexp end |
#regexp_capture_index ⇒ Object
25 26 27 |
# File 'lib/grape/router/base_route.rb', line 25 def regexp_capture_index @regexp_capture_index ||= CaptureIndexCache[@index] end |
#to_regexp(index) ⇒ Object
33 34 35 36 |
# File 'lib/grape/router/base_route.rb', line 33 def to_regexp(index) @index = index Regexp.new("(?<#{regexp_capture_index}>#{pattern_regexp})") end |