mongodb 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,7 +57,10 @@ module Mongo::Object
57
57
  raise("unknow class name for model #{h.inspect}!")
58
58
  end
59
59
  end
60
- alias_method :to_hash, :to_mongo
60
+
61
+ def to_hash
62
+ {}.tap{|h| to_mongo.each{|k, v| h[k.to_sym] = v}}
63
+ end
61
64
 
62
65
  # Override it to generate Your custom ids.
63
66
  def generate_id
@@ -20,4 +20,13 @@ describe "Miscellaneous" do
20
20
  o._id.should be_a(String)
21
21
  o._id.size.should == Mongo.defaults[:random_string_id_size]
22
22
  end
23
+
24
+ it "shoud convert to hash" do
25
+ class Tmp
26
+ attr_accessor :name
27
+ end
28
+ o = Tmp.new
29
+ o.name = 'some name'
30
+ o.to_hash.should == {name: 'some name', _class: 'Tmp'}
31
+ end
23
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-18 00:00:00.000000000Z
12
+ date: 2011-11-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongo
16
- requirement: &2849750 !ruby/object:Gem::Requirement
16
+ requirement: &2849860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2849750
24
+ version_requirements: *2849860
25
25
  description:
26
26
  email:
27
27
  executables: []