mince_dynamo_db 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,10 +60,6 @@ module MinceDynamoDb # :nodoc:
|
|
60
60
|
raise %(The method `MinceDynamoDb::DataStore.singleton.delete_field` is not implemented, you should implement it for us!)
|
61
61
|
end
|
62
62
|
|
63
|
-
def delete_by_params(collection_name, params)
|
64
|
-
raise %(The method `MinceDynamoDb::DataStore.singleton.delete_by_params` is not implemented, you should implement it for us!)
|
65
|
-
end
|
66
|
-
|
67
63
|
def delete_collection(collection_name)
|
68
64
|
raise %(The method `MinceDynamoDb::DataStore.singleton.delete_collection` is not implemented, you should implement it for us!)
|
69
65
|
end
|
@@ -200,6 +196,12 @@ module MinceDynamoDb # :nodoc:
|
|
200
196
|
array_to_hash items(collection_name).where(key.to_sym).contains(value)
|
201
197
|
end
|
202
198
|
|
199
|
+
# Deletes a record that matches the given criteria from the data store.
|
200
|
+
def delete_by_params(collection_name, params)
|
201
|
+
item = items(collection_name).where(params).first
|
202
|
+
item.delete
|
203
|
+
end
|
204
|
+
|
203
205
|
# Clears the data store.
|
204
206
|
# Mainly used for rolling back the data store in tests.
|
205
207
|
def clear
|
data/spec/lib/data_store_spec.rb
CHANGED
@@ -78,6 +78,14 @@ describe MinceDynamoDb::DataStore do
|
|
78
78
|
subject.find(collection_name, field, value).should == hash
|
79
79
|
end
|
80
80
|
|
81
|
+
it 'can delete a record that matches a criteria' do
|
82
|
+
params = mock 'params'
|
83
|
+
items.should_receive(:where).with(params).and_return([return_data])
|
84
|
+
return_data.should_receive(:delete)
|
85
|
+
|
86
|
+
subject.delete_by_params(collection_name, params)
|
87
|
+
end
|
88
|
+
|
81
89
|
it 'can clear the data store' do
|
82
90
|
item = mock 'item', delete: nil
|
83
91
|
item2 = mock 'item 2', delete: nil
|