mince 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,8 +23,8 @@ module Mince
23
23
  collection(collection_name).update({"_id" => hash[:_id]}, hash)
24
24
  end
25
25
 
26
- def update_field_with_value(*args)
27
- raise %(The method `Mince::DataStore.singleton.update_field_with_value` is not implemented, you should implement it for us!)
26
+ def update_field_with_value(collection_name, primary_key_value, field_name, new_value)
27
+ collection(collection_name).update({"_id" => primary_key_value}, {'$set' => { field_name => new_value } })
28
28
  end
29
29
 
30
30
  def get_all_for_key_with_value(collection_name, key, value)
data/lib/mince/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mince
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -41,6 +41,15 @@ describe Mince::DataStore do
41
41
  subject.add(collection_name, data).should == return_data
42
42
  end
43
43
 
44
+ it 'can update a field with a specific value' do
45
+ key = mock 'key'
46
+ value = mock 'value'
47
+ id = mock 'id'
48
+ collection.should_receive(:update).with({ '_id' => id }, { '$set' => { key => value } })
49
+
50
+ subject.update_field_with_value collection_name, id, key, value
51
+ end
52
+
44
53
  it 'can read from the collection' do
45
54
  collection.should_receive(:find).and_return(return_data)
46
55
 
@@ -107,4 +116,4 @@ describe Mince::DataStore do
107
116
 
108
117
  subject.remove_from_array(collection_name, :key, "value", :array_key, "value_to_remove").should == return_data
109
118
  end
110
- end
119
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mince
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-08 00:00:00.000000000 Z
14
+ date: 2012-05-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport