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

- (TreeManager) initialize(engine)



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

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

Instance Attribute Details

- (Object) ast (readonly)

Returns the value of attribute ast



5
6
7
# File 'lib/arel/tree_manager.rb', line 5

def ast
  @ast
end

- (Object) bind_values

Returns the value of attribute bind_values



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

def bind_values
  @bind_values
end

- (Object) engine (readonly)

Returns the value of attribute engine



5
6
7
# File 'lib/arel/tree_manager.rb', line 5

def engine
  @engine
end

Instance Method Details

- (Object) initialize_copy(other)



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

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

- (Object) to_dot



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

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

- (Object) to_sql



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

def to_sql
  visitor.accept @ast
end

- (Object) visitor



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

def visitor
  engine.connection.visitor
end

- (Object) where(expr)



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

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