Class: Grape::Router::Pattern
- Inherits:
-
Object
- Object
- Grape::Router::Pattern
- 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 =
%i[format version].freeze
Instance Attribute Summary collapse
-
#capture ⇒ Object
readonly
Returns the value of attribute capture.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern, **options) ⇒ Pattern
constructor
A new instance of Pattern.
- #to_regexp ⇒ Object
Constructor Details
#initialize(pattern, **options) ⇒ Pattern
Returns a new instance of Pattern.
19 20 21 22 23 24 25 |
# File 'lib/grape/router/pattern.rb', line 19 def initialize(pattern, **) @origin = pattern @path = build_path(pattern, **) @capture = extract_capture(**) @pattern = Mustermann.new(@path, **) @regexp = to_regexp end |
Instance Attribute Details
#capture ⇒ Object (readonly)
Returns the value of attribute capture.
12 13 14 |
# File 'lib/grape/router/pattern.rb', line 12 def capture @capture end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
12 13 14 |
# File 'lib/grape/router/pattern.rb', line 12 def origin @origin end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/grape/router/pattern.rb', line 12 def path @path end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
12 13 14 |
# File 'lib/grape/router/pattern.rb', line 12 def pattern @pattern end |
Instance Method Details
#to_regexp ⇒ Object
27 28 29 |
# File 'lib/grape/router/pattern.rb', line 27 def to_regexp @to_regexp ||= @pattern.to_regexp end |