diff options
Diffstat (limited to 'lib/arel/visitors/visitor.rb')
-rw-r--r-- | lib/arel/visitors/visitor.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/arel/visitors/visitor.rb b/lib/arel/visitors/visitor.rb index b96b8238a7..f156be9a0a 100644 --- a/lib/arel/visitors/visitor.rb +++ b/lib/arel/visitors/visitor.rb @@ -6,12 +6,14 @@ module Arel @dispatch = get_dispatch_cache end - def accept object - visit object + def accept object, *args + visit object, *args end private + attr_reader :dispatch + def self.dispatch_cache Hash.new do |hash, klass| hash[klass] = "visit_#{(klass.name || '').gsub('::', '_')}" @@ -22,14 +24,11 @@ module Arel self.class.dispatch_cache end - def dispatch - @dispatch - end - - def visit object - send dispatch[object.class], object + def visit object, *args + dispatch_method = dispatch[object.class] + send dispatch_method, object, *args rescue NoMethodError => e - raise e if respond_to?(dispatch[object.class], true) + raise e if respond_to?(dispatch_method, true) superklass = object.class.ancestors.find { |klass| respond_to?(dispatch[klass], true) } |