Class: Arel::TreeManager

Inherits:
Object show all
Includes:
FactoryMethods
Defined in:
activerecord/lib/arel/tree_manager.rb

Defined Under Namespace

Modules: StatementMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FactoryMethods

#coalesce, #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.



43
44
45
# File 'activerecord/lib/arel/tree_manager.rb', line 43

def initialize
  @ctx = nil
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast



41
42
43
# File 'activerecord/lib/arel/tree_manager.rb', line 41

def ast
  @ast
end

Instance Method Details

#initialize_copy(other) ⇒ Object



59
60
61
62
# File 'activerecord/lib/arel/tree_manager.rb', line 59

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

#to_dotObject



47
48
49
50
51
# File 'activerecord/lib/arel/tree_manager.rb', line 47

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

#to_sql(engine = Table.engine) ⇒ Object



53
54
55
56
57
# File 'activerecord/lib/arel/tree_manager.rb', line 53

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

#where(expr) ⇒ Object



64
65
66
67
68
69
70
# File 'activerecord/lib/arel/tree_manager.rb', line 64

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