Class: Grape::Router::BaseRoute

Inherits:
Object
  • Object
show all
Defined in:
lib/grape/router/base_route.rb

Direct Known Subclasses

GreedyRoute, Route

Defined Under Namespace

Classes: CaptureIndexCache

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  @options = ActiveSupport::OrderedOptions.new.update(options)
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



8
9
10
# File 'lib/grape/router/base_route.rb', line 8

def index
  @index
end

#optionsObject (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
  @options
end

#patternObject (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_regexpObject



20
21
22
# File 'lib/grape/router/base_route.rb', line 20

def pattern_regexp
  pattern.to_regexp
end

#regexp_capture_indexObject



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