Class: Wayfarer::Routing::Matchers::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/wayfarer/routing/matchers/path.rb

Constant Summary collapse

PATTERN_TYPE =
"sinatra"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Path

Returns a new instance of Path.



11
12
13
# File 'lib/wayfarer/routing/matchers/path.rb', line 11

def initialize(pattern)
  @pattern = Mustermann.new(pattern, type: PATTERN_TYPE)
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



9
10
11
# File 'lib/wayfarer/routing/matchers/path.rb', line 9

def pattern
  @pattern
end

Instance Method Details

#evaluate(path_finder) ⇒ Object



15
16
17
# File 'lib/wayfarer/routing/matchers/path.rb', line 15

def evaluate(path_finder)
  path_finder.path_consumer.current_state.valid?
end

#params(path_finder) ⇒ Object



19
20
21
# File 'lib/wayfarer/routing/matchers/path.rb', line 19

def params(path_finder)
  path_finder.path_consumer.current_state.params
end

#to_hObject



23
24
25
# File 'lib/wayfarer/routing/matchers/path.rb', line 23

def to_h
  { pattern: pattern.to_s }
end