aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/reduce.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-09-22 11:01:03 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-09-22 11:01:03 -0700
commitb57a11cb8abfca345f63084ce841c6f412c1156e (patch)
treec58702c92ba90e121a4556bc4053a0e6b790873f /lib/arel/visitors/reduce.rb
parentc903c6b28933a041d42d943c6c83f98aaa81f42a (diff)
downloadrails-b57a11cb8abfca345f63084ce841c6f412c1156e.tar.gz
rails-b57a11cb8abfca345f63084ce841c6f412c1156e.tar.bz2
rails-b57a11cb8abfca345f63084ce841c6f412c1156e.zip
move the dispatch table to be per-instance
visitors are not shared among threads, so any mutations to the cache should be OK. The cache is also pre-populated on construction, but we should pull that out so we can share the cache among visitors in the future.
Diffstat (limited to 'lib/arel/visitors/reduce.rb')
-rw-r--r--lib/arel/visitors/reduce.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/arel/visitors/reduce.rb b/lib/arel/visitors/reduce.rb
index 9670cad27c..1d74934fe5 100644
--- a/lib/arel/visitors/reduce.rb
+++ b/lib/arel/visitors/reduce.rb
@@ -10,14 +10,14 @@ module Arel
private
def visit object, collector
- send dispatch[object.class], object, collector
+ send dispatch[object.class.name], object, collector
rescue NoMethodError => e
- raise e if respond_to?(dispatch[object.class], true)
+ raise e if respond_to?(dispatch[object.class.name], true)
superklass = object.class.ancestors.find { |klass|
- respond_to?(dispatch[klass], true)
+ respond_to?(dispatch[klass.name], true)
}
raise(TypeError, "Cannot visit #{object.class}") unless superklass
- dispatch[object.class] = dispatch[superklass]
+ dispatch[object.class.name] = dispatch[superklass.name]
retry
end
end