Module: DataMapper::Adapters::DataObjectsAdapterAdjust
- Includes:
- SQL
- Defined in:
- lib/dm-adjust/adapters/data_objects_adapter.rb
Defined Under Namespace
Modules: SQL
Instance Method Summary collapse
Instance Method Details
#adjust(attributes, collection) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dm-adjust/adapters/data_objects_adapter.rb', line 4 def adjust(attributes, collection) query = collection.query # TODO: if the query contains any links, a limit or an offset # use a subselect to get the rows to be updated properties = [] bind_values = [] # make the order of the properties consistent query.model.properties(name).each do |property| next unless attributes.key?(property) properties << property bind_values << attributes[property] end statement, conditions_bind_values = adjust_statement(properties, query) bind_values.concat(conditions_bind_values) execute(statement, *bind_values).affected_rows end |