Class: Wayfarer::Routing::Route

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
DSL, Stringify
Defined in:
lib/wayfarer/routing/route.rb

Direct Known Subclasses

RootRoute, TargetRoute

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Stringify

#to_s

Methods included from DSL

#custom, #host, #path, #query, #scheme, #suffix, #to, #url

Constructor Details

#initialize(matcher = Matchers::Custom.new { children.any? }, path_offset = "/") ⇒ Route

Returns a new instance of Route.



21
22
23
24
25
# File 'lib/wayfarer/routing/route.rb', line 21

def initialize(matcher = Matchers::Custom.new { children.any? }, path_offset = "/")
  @matcher = matcher
  @children = []
  @path_offset = path_offset
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



12
13
14
# File 'lib/wayfarer/routing/route.rb', line 12

def action
  @action
end

#childrenObject (readonly)

Returns the value of attribute children.



10
11
12
# File 'lib/wayfarer/routing/route.rb', line 10

def children
  @children
end

#matcherObject

Returns the value of attribute matcher.



12
13
14
# File 'lib/wayfarer/routing/route.rb', line 12

def matcher
  @matcher
end

#parentObject

Returns the value of attribute parent.



12
13
14
# File 'lib/wayfarer/routing/route.rb', line 12

def parent
  @parent
end

#path_offsetObject

Returns the value of attribute path_offset.



12
13
14
# File 'lib/wayfarer/routing/route.rb', line 12

def path_offset
  @path_offset
end

Instance Method Details

#accept(visitor) ⇒ Object

Accepts a visitor for in-order traversal.



28
29
30
31
32
# File 'lib/wayfarer/routing/route.rb', line 28

def accept(visitor)
  return unless visitor.visit(self)

  children.each { |child| child.accept(visitor) }
end