Class: DB::Model::Statement::Update

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

Instance Method Summary collapse

Constructor Details

#initialize(source, assignment, where) ⇒ Update

Returns a new instance of Update.



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

def initialize(source, assignment, where)
	@source = source
	@assignment = assignment
	@where = where
end

Instance Method Details

#call(context) ⇒ Object



48
49
50
# File 'lib/db/model/statement/update.rb', line 48

def call(context)
	to_sql(context).call
end

#to_sql(context) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/db/model/statement/update.rb', line 33

def to_sql(context)
	statement = context.query("UPDATE")
	
	statement.identifier(@source.type)
	
	@assignment.append_to(statement)
	
	if @where
		statement.clause "WHERE"
		@where.append_to(statement)
	end
	
	return statement
end