mongoid 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongoid/contexts/enumerable.rb +3 -1
- data/lib/mongoid/contexts/mongo.rb +2 -0
- data/lib/mongoid/criteria.rb +2 -0
- data/lib/mongoid/railtie.rb +5 -0
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +1 -1
- data/lib/mongoid/relations/embedded/many.rb +1 -1
- data/lib/mongoid/relations/metadata.rb +13 -2
- data/lib/mongoid/version.rb +1 -1
- metadata +20 -20
@@ -42,8 +42,10 @@ module Mongoid #:nodoc:
|
|
42
42
|
#
|
43
43
|
# @return [ Integer ] The count of documents.
|
44
44
|
def count
|
45
|
-
@count ||=
|
45
|
+
@count ||= execute.size
|
46
46
|
end
|
47
|
+
alias :length :count
|
48
|
+
alias :size :count
|
47
49
|
|
48
50
|
# Delete all the documents in the database matching the selector.
|
49
51
|
#
|
data/lib/mongoid/criteria.rb
CHANGED
data/lib/mongoid/railtie.rb
CHANGED
@@ -111,6 +111,11 @@ module Rails #:nodoc:
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
# Need to include the Mongoid identity map middleware.
|
115
|
+
initializer "include the identity map" do |app|
|
116
|
+
app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap"
|
117
|
+
end
|
118
|
+
|
114
119
|
# Instantitate any registered observers after Rails initialization and
|
115
120
|
# instantiate them after being reloaded in the development environment
|
116
121
|
initializer "instantiate observers" do
|
@@ -112,7 +112,7 @@ module Mongoid # :nodoc:
|
|
112
112
|
# attrs: The single document attributes to process.
|
113
113
|
def process(attrs)
|
114
114
|
return if reject?(attrs)
|
115
|
-
if id = attrs[
|
115
|
+
if id = attrs["id"] || attrs["_id"]
|
116
116
|
document = existing.find(convert_id(id))
|
117
117
|
destroyable?(attrs) ? existing.delete(document) : document.update_attributes(attrs)
|
118
118
|
else
|
@@ -391,6 +391,16 @@ module Mongoid # :nodoc:
|
|
391
391
|
@inverse_klass ||= inverse_class_name.constantize
|
392
392
|
end
|
393
393
|
|
394
|
+
# Get the metadata for the inverse relation.
|
395
|
+
#
|
396
|
+
# @example Get the inverse metadata.
|
397
|
+
# metadata.inverse_metadata(doc)
|
398
|
+
#
|
399
|
+
# @param [ Document ] document The document to check.
|
400
|
+
#
|
401
|
+
# @return [ Metadata ] The inverse metadata.
|
402
|
+
#
|
403
|
+
# @since 2.1.0
|
394
404
|
def inverse_metadata(document)
|
395
405
|
document.reflect_on_association(inverse(document))
|
396
406
|
end
|
@@ -767,9 +777,10 @@ module Mongoid # :nodoc:
|
|
767
777
|
#
|
768
778
|
# @since 2.0.0.rc.1
|
769
779
|
def determine_inverse_relation
|
780
|
+
default = klass.relations[inverse_klass.name.underscore]
|
781
|
+
return default.name if default
|
770
782
|
klass.relations.each_pair do |key, meta|
|
771
|
-
if
|
772
|
-
meta.class_name == inverse_class_name
|
783
|
+
if meta.class_name == inverse_class_name
|
773
784
|
return key.to_sym
|
774
785
|
end
|
775
786
|
end
|
data/lib/mongoid/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
|
-
requirement: &
|
17
|
+
requirement: &2151774380 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2151774380
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: tzinfo
|
28
|
-
requirement: &
|
28
|
+
requirement: &2151772820 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.3.22
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2151772820
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: mongo
|
39
|
-
requirement: &
|
39
|
+
requirement: &2151770980 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '1.3'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2151770980
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rdoc
|
50
|
-
requirement: &
|
50
|
+
requirement: &2151758560 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 3.5.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2151758560
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: bson_ext
|
61
|
-
requirement: &
|
61
|
+
requirement: &2151755800 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,21 +66,21 @@ dependencies:
|
|
66
66
|
version: '1.3'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2151755800
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: mocha
|
72
|
-
requirement: &
|
72
|
+
requirement: &2151752500 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 0.9.8
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2151752500
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rspec
|
83
|
-
requirement: &
|
83
|
+
requirement: &2151750800 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,18 +88,18 @@ dependencies:
|
|
88
88
|
version: '2.6'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2151750800
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: watchr
|
94
|
-
requirement: &
|
94
|
+
requirement: &2151748540 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - ~>
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0.6'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2151748540
|
103
103
|
description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
|
104
104
|
in Ruby.
|
105
105
|
email:
|
@@ -380,7 +380,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
380
380
|
version: '0'
|
381
381
|
segments:
|
382
382
|
- 0
|
383
|
-
hash:
|
383
|
+
hash: 1067199592280239396
|
384
384
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
385
385
|
none: false
|
386
386
|
requirements:
|