class Arel::Visitors::Visitor - arel-4.0.2 Documentation

# class Arel::Visitors::Visitor

### Constants

DISPATCH

### Public Instance Methods

accept(object) click to toggle source

    # File lib/arel/visitors/visitor.rb, line 4
    def accept object
      visit object
    end

### Private Instance Methods

dispatch() click to toggle source

    # File lib/arel/visitors/visitor.rb, line 17
    def dispatch
      DISPATCH[self.class]
    end

visit(object, attribute = nil) click to toggle source

    # File lib/arel/visitors/visitor.rb, line 21
    def visit object, attribute = nil
      send dispatch[object.class], object, attribute
    rescue NoMethodError => e
      raise e if respond_to?(dispatch[object.class], 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