aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/tree_manager.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/tree_manager.rb')
-rw-r--r--lib/arel/tree_manager.rb17
1 files changed, 2 insertions, 15 deletions
diff --git a/lib/arel/tree_manager.rb b/lib/arel/tree_manager.rb
index fb5037cd9f..8a13345c91 100644
--- a/lib/arel/tree_manager.rb
+++ b/lib/arel/tree_manager.rb
@@ -3,30 +3,17 @@ module Arel
# FIXME: Remove this.
include Arel::Relation
- VISITORS = {
- 'postgresql' => Arel::Visitors::PostgreSQL,
- 'mysql' => Arel::Visitors::MySQL,
- 'mysql2' => Arel::Visitors::MySQL,
- }
-
- attr_writer :visitor
+ attr_accessor :visitor
def initialize engine
@engine = engine
- @visitor = nil
+ @visitor = Visitors.visitor_for @engine
end
def to_dot
Visitors::Dot.new.accept @head
end
- def visitor
- return @visitor if @visitor
- pool = @engine.connection_pool
- adapter = pool.spec.config[:adapter]
- @visitor = (VISITORS[adapter] || Visitors::ToSql).new(@engine)
- end
-
def to_sql
visitor.accept @head
end