diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-11 16:37:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-11 16:37:16 -0700 |
commit | bd6adc877af4687aec636f08e96e19785eea209d (patch) | |
tree | e61b114c5ade9d091611974ed1694370c0d54c57 /lib/arel/visitors | |
parent | a1a46fd8c2a3d53e02e2e58ca575b2596646b2c3 (diff) | |
parent | d93a05eec1adc5ca9d752a1e0b33313fc092c3e7 (diff) | |
download | rails-bd6adc877af4687aec636f08e96e19785eea209d.tar.gz rails-bd6adc877af4687aec636f08e96e19785eea209d.tar.bz2 rails-bd6adc877af4687aec636f08e96e19785eea209d.zip |
Merge pull request #204 from trptcolin/visitor_dispatch_caching
Cache visitor dispatch on a per-visitor basis
Diffstat (limited to 'lib/arel/visitors')
-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 |