Method: DataMapper::Adapters::InMemoryAdapter#delete

Defined in:
lib/dm-core/adapters/in_memory_adapter.rb

#delete(collection) ⇒ Integer

Destroys all the records matching the given query. “DELETE” in SQL.

Parameters:

Returns:

  • (Integer)

    The number of records that were deleted.



70
71
72
73
74
75
# File 'lib/dm-core/adapters/in_memory_adapter.rb', line 70

def delete(collection)
  records = records_for(collection.model)
  records_to_delete = collection.query.filter_records(records.dup)
  records.replace(records - records_to_delete)
  records_to_delete.size
end