Class: Arel::TreeManager

Inherits:
Object
  • Object
show all
Includes:
FactoryMethods
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

#initializeTreeManager

Returns a new instance of TreeManager.



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

def initialize
  @ctx    = nil
  @bind_values = []
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



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

def ast
  @ast
end

#bind_valuesObject

Returns the value of attribute bind_values.



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

def bind_values
  @bind_values
end

#engineObject (readonly)

Returns the value of attribute engine.



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

def engine
  @engine
end

Instance Method Details

#initialize_copy(other) ⇒ Object



29
30
31
32
# File 'lib/arel/tree_manager.rb', line 29

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

#to_dotObject



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

def to_dot
  collector = Arel::Collectors::PlainString.new
  collector = Visitors::Dot.new.accept @ast, collector
  collector.value
end

#to_sql(engine = Table.engine) ⇒ Object



23
24
25
26
27
# File 'lib/arel/tree_manager.rb', line 23

def to_sql engine = Table.engine
  collector = Arel::Collectors::SQLString.new
  collector = engine.connection.visitor.accept @ast, collector
  collector.value
end

#where(expr) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/arel/tree_manager.rb', line 34

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