Module: Returning::Rails30::Arel::Crud
- Defined in:
- lib/returning/rails30/arel/crud.rb
Instance Method Summary collapse
Instance Method Details
#delete ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/returning/rails30/arel/crud.rb', line 27 def delete dm = ::Arel::DeleteManager.new @engine dm.wheres = @ctx.wheres dm.from @ctx.froms dm.returning @ctx.returnings if @ctx.returnings if @ctx.returnings @engine.connection.select_all dm.to_sql, 'AREL' else @engine.connection.delete dm.to_sql, 'AREL' end end |
#update(values) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/returning/rails30/arel/crud.rb', line 5 def update values um = ::Arel::UpdateManager.new @engine if ::Arel::Nodes::SqlLiteral === values relation = @ctx.froms else relation = values.first.first.relation end um.table relation um.set values um.take @ast.limit.expr if @ast.limit um.order(*@ast.orders) um.wheres = @ctx.wheres um.returning @ctx.returnings if @ctx.returnings if @ctx.returnings @engine.connection.select_all um.to_sql, 'AREL' else @engine.connection.update um.to_sql, 'AREL' end end |