Class: Arel::TreeManager

Inherits:
Object
  • Object
show all
Includes:
FactoryMethods, Relation
Defined in:
lib/arel/tree_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FactoryMethods

#create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower

Constructor Details

#initialize(engine) ⇒ TreeManager

Returns a new instance of TreeManager.



9
10
11
12
# File 'lib/arel/tree_manager.rb', line 9

def initialize engine
  @engine = engine
  @ctx    = nil
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



7
8
9
# File 'lib/arel/tree_manager.rb', line 7

def ast
  @ast
end

#engineObject (readonly)

Returns the value of attribute engine.



7
8
9
# File 'lib/arel/tree_manager.rb', line 7

def engine
  @engine
end

Instance Method Details

#initialize_copy(other) ⇒ Object



26
27
28
29
# File 'lib/arel/tree_manager.rb', line 26

def initialize_copy other
  super
  @ast = @ast.clone
end

#to_dotObject



14
15
16
# File 'lib/arel/tree_manager.rb', line 14

def to_dot
  Visitors::Dot.new.accept @ast
end

#to_sqlObject



22
23
24
# File 'lib/arel/tree_manager.rb', line 22

def to_sql
  visitor.accept @ast
end

#visitorObject



18
19
20
# File 'lib/arel/tree_manager.rb', line 18

def visitor
  engine.connection.visitor
end

#where(expr) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/arel/tree_manager.rb', line 31

def where expr
  if Arel::TreeManager === expr
    expr = expr.ast
  end
  @ctx.wheres << expr
  self
end