Methods

DataMapper::Adapters::DataObjectsAdapterAdjust

Public Instance Methods

adjust(attributes, collection) click to toggle source
# 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.