mongo_mapper 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mongo_mapper/support.rb +44 -0
- data/mongo_mapper.gemspec +2 -3
- data/test/unit/test_support.rb +0 -2
- metadata +2 -3
- data/lib/mongo_mapper/types.rb +0 -64
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
data/lib/mongo_mapper/support.rb
CHANGED
@@ -15,6 +15,34 @@ class Array
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
class Binary
|
19
|
+
def self.to_mongo(value)
|
20
|
+
if value.is_a?(ByteBuffer)
|
21
|
+
value
|
22
|
+
else
|
23
|
+
value.nil? ? nil : ByteBuffer.new(value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.from_mongo(value)
|
28
|
+
value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Boolean
|
33
|
+
def self.to_mongo(value)
|
34
|
+
if value.is_a?(Boolean)
|
35
|
+
value
|
36
|
+
else
|
37
|
+
['true', 't', '1'].include?(value.to_s.downcase)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.from_mongo(value)
|
42
|
+
!!value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
18
46
|
class Date
|
19
47
|
def self.to_mongo(value)
|
20
48
|
date = Date.parse(value.to_s)
|
@@ -94,6 +122,22 @@ class Object
|
|
94
122
|
end
|
95
123
|
end
|
96
124
|
|
125
|
+
class ObjectId
|
126
|
+
def self.to_mongo(value)
|
127
|
+
if value.nil?
|
128
|
+
nil
|
129
|
+
elsif value.is_a?(Mongo::ObjectID)
|
130
|
+
value
|
131
|
+
else
|
132
|
+
Mongo::ObjectID.from_string(value.to_s)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.from_mongo(value)
|
137
|
+
value
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
97
141
|
class Set
|
98
142
|
def self.to_mongo(value)
|
99
143
|
value.to_a
|
data/mongo_mapper.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongo_mapper}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Nunemaker"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-24}
|
13
13
|
s.default_executable = %q{mmconsole}
|
14
14
|
s.email = %q{nunemaker@gmail.com}
|
15
15
|
s.executables = ["mmconsole"]
|
@@ -50,7 +50,6 @@ Gem::Specification.new do |s|
|
|
50
50
|
"lib/mongo_mapper/serialization.rb",
|
51
51
|
"lib/mongo_mapper/serializers/json_serializer.rb",
|
52
52
|
"lib/mongo_mapper/support.rb",
|
53
|
-
"lib/mongo_mapper/types.rb",
|
54
53
|
"lib/mongo_mapper/validations.rb",
|
55
54
|
"mongo_mapper.gemspec",
|
56
55
|
"specs.watchr",
|
data/test/unit/test_support.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-24 00:00:00 -05:00
|
13
13
|
default_executable: mmconsole
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -124,7 +124,6 @@ files:
|
|
124
124
|
- lib/mongo_mapper/serialization.rb
|
125
125
|
- lib/mongo_mapper/serializers/json_serializer.rb
|
126
126
|
- lib/mongo_mapper/support.rb
|
127
|
-
- lib/mongo_mapper/types.rb
|
128
127
|
- lib/mongo_mapper/validations.rb
|
129
128
|
- mongo_mapper.gemspec
|
130
129
|
- specs.watchr
|
data/lib/mongo_mapper/types.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module MongoMapper
|
2
|
-
module Types
|
3
|
-
class Binary
|
4
|
-
def self.to_mongo(value)
|
5
|
-
if value.is_a?(ByteBuffer)
|
6
|
-
value
|
7
|
-
else
|
8
|
-
value.nil? ? nil : ByteBuffer.new(value)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.from_mongo(value)
|
13
|
-
value
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Boolean
|
18
|
-
def self.to_mongo(value)
|
19
|
-
if value.is_a?(Boolean)
|
20
|
-
value
|
21
|
-
else
|
22
|
-
['true', 't', '1'].include?(value.to_s.downcase)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.from_mongo(value)
|
27
|
-
!!value
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class ObjectId
|
32
|
-
def self.to_mongo(value)
|
33
|
-
if value.nil?
|
34
|
-
nil
|
35
|
-
elsif value.is_a?(Mongo::ObjectID)
|
36
|
-
value
|
37
|
-
else
|
38
|
-
Mongo::ObjectID.from_string(value.to_s)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.from_mongo(value)
|
43
|
-
value
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# This allows using just Boolean when defining
|
48
|
-
# keys instead of MongoMapper::Types::Boolean
|
49
|
-
module Lookup
|
50
|
-
def const_missing(name)
|
51
|
-
if MongoMapper::Types.const_defined?(name)
|
52
|
-
MongoMapper::Types.const_get(name)
|
53
|
-
else
|
54
|
-
super
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# This was required to get in front of ActiveSupports Class#const_missing
|
62
|
-
Class.instance_eval do
|
63
|
-
include MongoMapper::Types::Lookup
|
64
|
-
end
|