mongodb 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongo/object/object.rb +4 -1
- data/spec/object/miscellaneous_spec.rb +9 -0
- metadata +4 -4
data/lib/mongo/object/object.rb
CHANGED
@@ -57,7 +57,10 @@ module Mongo::Object
|
|
57
57
|
raise("unknow class name for model #{h.inspect}!")
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
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.
|
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-
|
12
|
+
date: 2011-11-19 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo
|
16
|
-
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: *
|
24
|
+
version_requirements: *2849860
|
25
25
|
description:
|
26
26
|
email:
|
27
27
|
executables: []
|