Class: Grape::Router::Pattern

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/grape/router/pattern.rb

Constant Summary collapse

DEFAULT_PATTERN_OPTIONS =
{ uri_decode: true, type: :grape }.freeze
DEFAULT_SUPPORTED_CAPTURE =
[:format, :version].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, **options) ⇒ Pattern

Returns a new instance of Pattern


17
18
19
20
21
22
23
# File 'lib/grape/router/pattern.rb', line 17

def initialize(pattern, **options)
  @origin  = pattern
  @path    = build_path(pattern, **options)
  @capture = extract_capture(options)
  @pattern = Mustermann.new(@path, pattern_options)
  @regexp  = to_regexp
end

Instance Attribute Details

#captureObject (readonly)

Returns the value of attribute capture


10
11
12
# File 'lib/grape/router/pattern.rb', line 10

def capture
  @capture
end

#originObject (readonly)

Returns the value of attribute origin


10
11
12
# File 'lib/grape/router/pattern.rb', line 10

def origin
  @origin
end

#pathObject (readonly)

Returns the value of attribute path


10
11
12
# File 'lib/grape/router/pattern.rb', line 10

def path
  @path
end

#patternObject (readonly)

Returns the value of attribute pattern


10
11
12
# File 'lib/grape/router/pattern.rb', line 10

def pattern
  @pattern
end

Instance Method Details

#to_regexpObject


25
26
27
# File 'lib/grape/router/pattern.rb', line 25

def to_regexp
  @to_regexp ||= @pattern.to_regexp
end