lib/journey/visitors.rb in journey-1.0.1 vs lib/journey/visitors.rb in journey-1.0.2

- old
+ new

@@ -1,15 +1,19 @@ # encoding: utf-8 module Journey module Visitors class Visitor # :nodoc: + DISPATCH_CACHE = Hash.new { |h,k| + h[k] = "visit_#{k}" + } + def accept node visit node end private def visit node - send "visit_#{node.type}", node + send DISPATCH_CACHE[node.type], node end def binary node visit node.left visit node.right