@api semipublic
# File lib/dm-yaml-adapter/adapter.rb, line 42 def attributes_as_fields(attributes) pairs = attributes.map do |property, value| dumped = value.kind_of?(Module) ? value.name : property.dump(value) [ property.field, dumped ] end Hash[pairs] end
@api semipublic
# File lib/dm-yaml-adapter/adapter.rb, line 8 def create(resources) update_records(resources.first.model) do |records| resources.each do |resource| initialize_serial(resource, records.size.succ) records << attributes_as_fields(resource.attributes(nil)) end end end
@api semipublic
# File lib/dm-yaml-adapter/adapter.rb, line 33 def delete(collection) update_records(collection.model) do |records| records_to_delete = collection.query.filter_records(records.dup) records.replace(records - records_to_delete) records_to_delete.size end end
@api semipublic
# File lib/dm-yaml-adapter/adapter.rb, line 18 def read(query) query.filter_records(records_for(query.model).dup) end
@api semipublic
# File lib/dm-yaml-adapter/adapter.rb, line 23 def update(attributes, collection) attributes = attributes_as_fields(attributes) update_records(collection.model) do |records| records_to_update = collection.query.filter_records(records.dup) records_to_update.each { |record| record.update(attributes) }.size end end
Generated with the Darkfish Rdoc Generator 2.