Class: DB::Model::Statement::Equal

Inherits:
Object
  • Object
show all
Defined in:
lib/db/model/statement/equal.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, fields, values) ⇒ Equal

Returns a new instance of Equal.



27
28
29
30
31
# File 'lib/db/model/statement/equal.rb', line 27

def initialize(source, fields, values)
  @source = source
  @fields = fields
  @values = values
end

Instance Method Details

#append_to(statement) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/db/model/statement/equal.rb', line 33

def append_to(statement)
  first = true
  
  @fields.each_with_index do |field, index|
    statement.clause("AND") unless first
    first = false
    
    if field.is_a?(Symbol)
      statement.identifier(field)
    else
      field.append_to(statement)
    end
    
    statement.clause("=")
    statement.literal(@values[index])
  end
  
  return statement
end