Class: Grape::Router::Pattern
- Inherits:
-
Object
- Object
- Grape::Router::Pattern
- Extended by:
- Forwardable
- Defined in:
- lib/grape/router/pattern.rb
Defined Under Namespace
Classes: PatternCache
Constant Summary collapse
- DEFAULT_CAPTURES =
%w[format version].freeze
Instance Attribute Summary collapse
-
#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.
-
#to_regexp ⇒ Object
readonly
Returns the value of attribute to_regexp.
Instance Method Summary collapse
- #captures_default ⇒ Object
-
#initialize(origin, suffix, options) ⇒ Pattern
constructor
A new instance of Pattern.
Constructor Details
#initialize(origin, suffix, options) ⇒ Pattern
Returns a new instance of Pattern.
16 17 18 19 20 21 |
# File 'lib/grape/router/pattern.rb', line 16 def initialize(origin, suffix, ) @origin = origin @path = build_path(origin, [:anchor], suffix) @pattern = build_pattern(@path, [:params], [:format], [:version], [:requirements]) @to_regexp = @pattern.to_regexp end |
Instance Attribute Details
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
10 11 12 |
# File 'lib/grape/router/pattern.rb', line 10 def origin @origin end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/grape/router/pattern.rb', line 10 def path @path end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
10 11 12 |
# File 'lib/grape/router/pattern.rb', line 10 def pattern @pattern end |
#to_regexp ⇒ Object (readonly)
Returns the value of attribute to_regexp.
10 11 12 |
# File 'lib/grape/router/pattern.rb', line 10 def to_regexp @to_regexp end |
Instance Method Details
#captures_default ⇒ Object
23 24 25 26 27 |
# File 'lib/grape/router/pattern.rb', line 23 def captures_default to_regexp.names .delete_if { |n| DEFAULT_CAPTURES.include?(n) } .to_h { |k| [k, ''] } end |