aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/visitor.rb
blob: 510d50399be27c64a8d1607808a247c124bdd3b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Arel
  module Visitors
    class Visitor
      def accept object
        visit object
      end

      private

      DISPATCH = Hash.new do |hash, klass|
        hash[klass] = "visit_#{klass.name.gsub('::', '_')}"
      end

      def visit object
        send DISPATCH[object.class], object
      end
    end
  end
end