diff options
author | Colin Jones <trptcolin@gmail.com> | 2013-08-14 17:02:17 -0500 |
---|---|---|
committer | Colin Jones <trptcolin@gmail.com> | 2013-08-14 17:02:17 -0500 |
commit | d93a05eec1adc5ca9d752a1e0b33313fc092c3e7 (patch) | |
tree | 7d03b1524adef2f462f579af15381d1423e3a416 /lib | |
parent | 4524c7f8a8225677893e0731f40993de17d4babc (diff) | |
download | rails-d93a05eec1adc5ca9d752a1e0b33313fc092c3e7.tar.gz rails-d93a05eec1adc5ca9d752a1e0b33313fc092c3e7.tar.bz2 rails-d93a05eec1adc5ca9d752a1e0b33313fc092c3e7.zip |
Cache visitor dispatch on a per-visitor basis
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/visitors/visitor.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/arel/visitors/visitor.rb b/lib/arel/visitors/visitor.rb index 204657883f..33ec5eafb4 100644 --- a/lib/arel/visitors/visitor.rb +++ b/lib/arel/visitors/visitor.rb @@ -7,12 +7,15 @@ module Arel private - DISPATCH = Hash.new do |hash, klass| - hash[klass] = "visit_#{(klass.name || '').gsub('::', '_')}" + DISPATCH = Hash.new do |hash, visitor_class| + hash[visitor_class] = + Hash.new do |hash, node_class| + hash[node_class] = "visit_#{(node_class.name || '').gsub('::', '_')}" + end end def dispatch - DISPATCH + DISPATCH[self.class] end def visit object, attribute = nil |