mongo_odm 0.2.16 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/mongo_odm.rb +12 -0
- data/lib/mongo_odm/core_ext/conversions.rb +16 -0
- data/lib/mongo_odm/document/indexes.rb +1 -0
- data/lib/mongo_odm/version.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -164,7 +164,7 @@ To embed just one copy of another class, just define the field type of that clas
|
|
164
164
|
index :name, :unique => true
|
165
165
|
end
|
166
166
|
|
167
|
-
Color.create_indexes
|
167
|
+
Color.create_indexes # You can also use MongoODM.create_indexes to create all the indexes at all classes at the same time
|
168
168
|
|
169
169
|
color = Color.new(:name => "red", :rgb => RGB.new(255,0,0))
|
170
170
|
color.save
|
data/lib/mongo_odm.rb
CHANGED
@@ -51,5 +51,17 @@ module MongoODM
|
|
51
51
|
def self.dereference(value)
|
52
52
|
value.respond_to?(:dereference) ? value.dereference : value
|
53
53
|
end
|
54
|
+
|
55
|
+
def self.indexed_classes
|
56
|
+
@_indexes ||= Set.new
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.create_indexes
|
60
|
+
indexed_classes.each {|klass| klass.create_indexes}
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.add_index_class(klass)
|
64
|
+
indexed_classes << klass
|
65
|
+
end
|
54
66
|
|
55
67
|
end
|
@@ -287,4 +287,20 @@ class NilClass
|
|
287
287
|
def to_mongo
|
288
288
|
nil
|
289
289
|
end
|
290
|
+
end
|
291
|
+
|
292
|
+
# @private
|
293
|
+
class Set
|
294
|
+
def self.type_cast(value)
|
295
|
+
return nil if value.nil?
|
296
|
+
Set.new(Array.type_cast(value))
|
297
|
+
end
|
298
|
+
|
299
|
+
def to_mongo
|
300
|
+
self.map {|elem| elem.to_mongo}
|
301
|
+
end
|
302
|
+
|
303
|
+
def dereference
|
304
|
+
MongoODM.instanciate(self.map{|value| MongoODM.dereference(value)})
|
305
|
+
end
|
290
306
|
end
|
data/lib/mongo_odm/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mongo_odm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.17
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Carlos Paramio
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-30 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|