Class: Wayfarer::Routing::Route
- Inherits:
-
Object
- Object
- Wayfarer::Routing::Route
- Includes:
- DSL
- Defined in:
- lib/wayfarer/routing/route.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#matcher ⇒ Object
Returns the value of attribute matcher.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#path_offset ⇒ Object
Returns the value of attribute path_offset.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
Accepts a visitor for in-order traversal.
-
#initialize(matcher = CustomMatcher.new { children.any? }, path_offset = "/") ⇒ Route
constructor
A new instance of Route.
- #invoke(url) ⇒ Object
- #match(url) ⇒ Object
- #matches?(url) ⇒ Boolean
Methods included from DSL
#custom, #host, #path, #query, #scheme, #suffix, #to, #url
Constructor Details
#initialize(matcher = CustomMatcher.new { children.any? }, path_offset = "/") ⇒ Route
Returns a new instance of Route.
15 16 17 18 19 |
# File 'lib/wayfarer/routing/route.rb', line 15 def initialize(matcher = CustomMatcher.new { children.any? }, path_offset = "/") @matcher = matcher @children = [] @path_offset = path_offset end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
10 11 12 |
# File 'lib/wayfarer/routing/route.rb', line 10 def action @action end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
8 9 10 |
# File 'lib/wayfarer/routing/route.rb', line 8 def children @children end |
#matcher ⇒ Object
Returns the value of attribute matcher.
10 11 12 |
# File 'lib/wayfarer/routing/route.rb', line 10 def matcher @matcher end |
#parent ⇒ Object
Returns the value of attribute parent.
10 11 12 |
# File 'lib/wayfarer/routing/route.rb', line 10 def parent @parent end |
#path_offset ⇒ Object
Returns the value of attribute path_offset.
10 11 12 |
# File 'lib/wayfarer/routing/route.rb', line 10 def path_offset @path_offset end |
Instance Method Details
#accept(visitor) ⇒ Object
Accepts a visitor for in-order traversal.
34 35 36 37 38 |
# File 'lib/wayfarer/routing/route.rb', line 34 def accept(visitor) return unless visitor.visit(self) children.each { |child| child.accept(visitor) } end |
#invoke(url) ⇒ Object
29 30 31 |
# File 'lib/wayfarer/routing/route.rb', line 29 def invoke(url) PathFinder.result(self, url) end |
#match(url) ⇒ Object
21 22 23 |
# File 'lib/wayfarer/routing/route.rb', line 21 def match(url) matcher.match(url) end |