mongomatic 0.0.6 → 0.0.7

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.
@@ -65,6 +65,10 @@ module Mongomatic
65
65
  @doc[k.to_s]
66
66
  end
67
67
 
68
+ def merge(hash)
69
+ hash.each { |k,v| self[k] = v }; @doc
70
+ end
71
+
68
72
  def removed?
69
73
  self.removed == true
70
74
  end
@@ -87,4 +87,15 @@ class TestMongomatic < Test::Unit::TestCase
87
87
 
88
88
  assert_equal 10, Person.find().limit(10).to_a.size
89
89
  end
90
+
91
+ should "be able to merge hashes" do
92
+ Person.collection.remove
93
+ p = Person.new(:name => "Ben", :birth_year => 1984, :created_at => Time.now.utc, :admin => true)
94
+ assert p.insert.is_a?(BSON::ObjectID)
95
+ assert_equal 1, Person.collection.count
96
+ p.merge(:birth_year => 1986)
97
+ p.update
98
+ p = Person.find({"_id" => p["_id"]}).next
99
+ assert_equal 1986, p["birth_year"]
100
+ end
90
101
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 6
9
- version: 0.0.6
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ben Myles
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-28 00:00:00 -07:00
17
+ date: 2010-07-29 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -157,4 +157,4 @@ specification_version: 3
157
157
  summary: Mongomatic is a simple Ruby object mapper for Mongo
158
158
  test_files:
159
159
  - test/helper.rb
160
- - test/test_meta_mongo.rb
160
+ - test/test_mongomatic.rb