Class: Update
- Inherits:
-
SqlStatement
- Object
- SqlStatement
- Update
- Defined in:
- lib/update.rb
Instance Attribute Summary
Attributes inherited from SqlStatement
Class Method Summary collapse
-
.[](table) ⇒ Object
call-seq: Update -> an_update.
Instance Method Summary collapse
-
#[](hash) ⇒ Object
call-seq: update -> an_update.
-
#set ⇒ Object
call-seq: update.set -> update.
Methods inherited from SqlStatement
#and, #and_with_or_conditions, #initialize, #or, #where
Constructor Details
This class inherits a constructor from SqlStatement
Class Method Details
.[](table) ⇒ Object
8 9 10 11 12 |
# File 'lib/update.rb', line 8 def [](table) update = self.new("update #{table.to_sql}") update.tables = [table] update end |
Instance Method Details
#[](hash) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/update.rb', line 30 def [](hash) @to_sql += " set " set_args = [] hash.each_pair do |col, val| set_args << "#{col.to_sql}=#{val.to_sql}" end @to_sql += set_args.sort.join(', ') self end |
#set ⇒ Object
call-seq: update.set -> update
Returns self. Unnecessary and only available to mimic SQL statements.
Update[:table1].set.to_sql #=> "update table1"
20 21 22 |
# File 'lib/update.rb', line 20 def set self end |