hashy_db 0.0.9 → 0.0.10

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.
@@ -31,6 +31,12 @@ module HashyDb
31
31
  collection[index] = hash
32
32
  end
33
33
 
34
+ def delete_by_params(collection_name, params)
35
+ find_all(collection_name).reject! do |record|
36
+ params.all?{|k,v| record[k] == v }
37
+ end
38
+ end
39
+
34
40
  def update_field_with_value(collection_name, primary_key_value, field_name, new_value)
35
41
  find(collection_name, :id, primary_key_value)[field_name] = new_value
36
42
  end
@@ -1,3 +1,3 @@
1
1
  module HashyDb
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
@@ -44,6 +44,14 @@ describe HashyDb::DataStore do
44
44
  end
45
45
  end
46
46
 
47
+ it 'can delete records that match a given set of fields' do
48
+ params = { id: 1, field_1: 'value 1' }
49
+
50
+ subject.delete_by_params(:some_collection, params)
51
+
52
+ subject.find_all(:some_collection).should == [data2, data3]
53
+ end
54
+
47
55
  it 'can write and read data to and from a collection' do
48
56
  data4 = {id: 3, field_1: 'value 3', field_2: 9, shared_between_1_and_2: 'not the same as 1 and 2', :some_array => [1, 7]}
49
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashy_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: