Sha256: 6a5704d9264e69f29de005b5ec23239a0a54040db1e5f82d5783139bdd12ab13

Contents?: true

Size: 731 Bytes

Versions: 4

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true
require 'arel/visitors/visitor'

module Arel
  module Visitors
    class Reduce < Arel::Visitors::Visitor
      def accept object, collector
        visit object, collector
      end

      private

      def visit object, collector
        dispatch_method = dispatch[object.class]
        send dispatch_method, object, collector
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
spiral_form-0.1.1 vendor/bundle/gems/arel-9.0.0/lib/arel/visitors/reduce.rb
spiral_form-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/visitors/reduce.rb
nullifyable-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/visitors/reduce.rb
arel-9.0.0 lib/arel/visitors/reduce.rb