Class: ActionDispatch::Journey::Visitors::FormatBuilder

Inherits:
Visitor
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/journey/visitors.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Visitor

Visitor::DISPATCH_CACHE

Instance Method Summary collapse

Instance Method Details

#accept(node) ⇒ Object


96
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 96

def accept(node); Journey::Format.new(super); end

#binary(node) ⇒ Object


99
100
101
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 99

def binary(node)
  visit(node.left) + visit(node.right)
end

#terminal(node) ⇒ Object


97
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 97

def terminal(node); [node.left]; end

#visit_GROUP(n) ⇒ Object


103
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 103

def visit_GROUP(n); [Journey::Format.new(unary(n))]; end

#visit_STAR(n) ⇒ Object


105
106
107
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 105

def visit_STAR(n)
  [Journey::Format.required_path(n.left.to_sym)]
end

#visit_SYMBOL(n) ⇒ Object


109
110
111
112
113
114
115
116
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 109

def visit_SYMBOL(n)
  symbol = n.to_sym
  if symbol == :controller
    [Journey::Format.required_path(symbol)]
  else
    [Journey::Format.required_segment(symbol)]
  end
end