Class: Arel::Visitors::Visitor
Do not use. This class is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | activerecord/lib/arel/visitors/visitor.rb |
Class Method Summary
- .new ⇒ Visitor constructor
- .dispatch_cache private
Instance Attribute Summary
- #dispatch readonly private
Instance Method Summary
Constructor Details
.new ⇒ Visitor
# File 'activerecord/lib/arel/visitors/visitor.rb', line 6
def initialize @dispatch = get_dispatch_cache end
Class Method Details
.dispatch_cache (private)
[ GitHub ]Instance Attribute Details
#dispatch (readonly, private)
[ GitHub ]# File 'activerecord/lib/arel/visitors/visitor.rb', line 15
attr_reader :dispatch
Instance Method Details
#accept(object, collector = nil)
[ GitHub ]# File 'activerecord/lib/arel/visitors/visitor.rb', line 10
def accept(object, collector = nil) visit object, collector end
#get_dispatch_cache (private)
[ GitHub ]# File 'activerecord/lib/arel/visitors/visitor.rb', line 23
def get_dispatch_cache self.class.dispatch_cache end
#visit(object, collector = nil) (private)
[ GitHub ]# File 'activerecord/lib/arel/visitors/visitor.rb', line 27
def visit(object, collector = nil) dispatch_method = dispatch[object.class] if collector send dispatch_method, object, collector else send dispatch_method, object end rescue NoMethodError => e raise e if respond_to?(dispatch_method, true) superklass = object.class.ancestors.find { |klass| respond_to?(dispatch[klass], true) } raise(TypeError, "Cannot visit #{object.class}") unless superklass dispatch[object.class] = dispatch[superklass] retry end