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.



10
11
12
13
14
# File 'lib/db/model/statement/equal.rb', line 10

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

Instance Method Details

#append_to(statement) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/db/model/statement/equal.rb', line 16

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