mongoid 3.0.11 → 3.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +18 -0
- data/lib/mongoid/attributes/processing.rb +3 -1
- data/lib/mongoid/document.rb +2 -0
- data/lib/mongoid/fields.rb +6 -5
- data/lib/mongoid/fields/standard.rb +11 -6
- data/lib/mongoid/hierarchy.rb +1 -0
- data/lib/mongoid/railtie.rb +1 -5
- data/lib/mongoid/relations/macros.rb +2 -2
- data/lib/mongoid/relations/referenced/many.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rack/mongoid/middleware/identity_map.rb +1 -37
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,24 @@
|
|
3
3
|
For instructions on upgrading to newer versions, visit
|
4
4
|
[mongoid.org](http://mongoid.org/docs/upgrading.html).
|
5
5
|
|
6
|
+
## 3.0.12
|
7
|
+
|
8
|
+
### Resolved Issues
|
9
|
+
|
10
|
+
* \#2542 Allow embedded documents using `store_as` to properly alias in
|
11
|
+
criteria.
|
12
|
+
|
13
|
+
* \#2541 Ensure that the type change is correct when upcasting/downcasting a
|
14
|
+
document via `Document#becomes` (Łukasz Bandzarewicz)
|
15
|
+
|
16
|
+
* \#2529 Fields on subclasses that override fields in the parent where both have
|
17
|
+
defaults with procs now properly override the default in the subclass.
|
18
|
+
|
19
|
+
* \#2528 Aliased fields need to be duped when subclassing.
|
20
|
+
|
21
|
+
* \#2527 Ensure removal of docs in a `has_many` does a multi update when setting
|
22
|
+
to an empty array.
|
23
|
+
|
6
24
|
## 3.0.11
|
7
25
|
|
8
26
|
### Resolved Issues
|
@@ -53,7 +53,9 @@ module Mongoid
|
|
53
53
|
# @return [ Hash ] The mass assignment options.
|
54
54
|
#
|
55
55
|
# @since 3.0.7
|
56
|
-
|
56
|
+
def mass_assignment_options=(options)
|
57
|
+
@mass_assignment_options = options
|
58
|
+
end
|
57
59
|
|
58
60
|
# If the key provided is the name of a relation or a nested attribute, we
|
59
61
|
# need to wait until all other attributes are set before processing
|
data/lib/mongoid/document.rb
CHANGED
@@ -217,12 +217,14 @@ module Mongoid
|
|
217
217
|
unless klass.include?(Mongoid::Document)
|
218
218
|
raise ArgumentError, "A class which includes Mongoid::Document is expected"
|
219
219
|
end
|
220
|
+
|
220
221
|
became = klass.new(as_document.__deep_copy__)
|
221
222
|
became.id = id
|
222
223
|
became.instance_variable_set(:@changed_attributes, changed_attributes)
|
223
224
|
became.instance_variable_set(:@errors, errors)
|
224
225
|
became.instance_variable_set(:@new_record, new_record?)
|
225
226
|
became.instance_variable_set(:@destroyed, destroyed?)
|
227
|
+
became.changed_attributes["_type"] = self.class.to_s
|
226
228
|
became._type = klass.to_s
|
227
229
|
became
|
228
230
|
end
|
data/lib/mongoid/fields.rb
CHANGED
@@ -444,8 +444,8 @@ module Mongoid
|
|
444
444
|
re_define_method("#{meth}_translations=") do |value|
|
445
445
|
attribute_will_change!(name)
|
446
446
|
if value
|
447
|
-
value.update_values do |
|
448
|
-
field.type.mongoize(
|
447
|
+
value.update_values do |_value|
|
448
|
+
field.type.mongoize(_value)
|
449
449
|
end
|
450
450
|
end
|
451
451
|
attributes[name] = value
|
@@ -483,9 +483,10 @@ module Mongoid
|
|
483
483
|
end
|
484
484
|
|
485
485
|
def field_for(name, options)
|
486
|
-
|
487
|
-
return Fields::
|
488
|
-
Fields::
|
486
|
+
opts = options.merge(klass: self)
|
487
|
+
return Fields::Localized.new(name, opts) if options[:localize]
|
488
|
+
return Fields::ForeignKey.new(name, opts) if options[:identity]
|
489
|
+
Fields::Standard.new(name, opts)
|
489
490
|
end
|
490
491
|
end
|
491
492
|
end
|
@@ -86,6 +86,13 @@ module Mongoid
|
|
86
86
|
@options = options
|
87
87
|
@label = options[:label]
|
88
88
|
@default_val = options[:default]
|
89
|
+
|
90
|
+
# @todo: Durran, change API in 4.0 to take the class as a parameter.
|
91
|
+
# This is here temporarily to address #2529 without changing the
|
92
|
+
# constructor signature.
|
93
|
+
if default_val.respond_to?(:call)
|
94
|
+
define_default_method(options[:klass])
|
95
|
+
end
|
89
96
|
end
|
90
97
|
|
91
98
|
# Is the field localized or not?
|
@@ -186,13 +193,12 @@ module Mongoid
|
|
186
193
|
#
|
187
194
|
# @note Ruby's instance_exec was just too slow.
|
188
195
|
#
|
189
|
-
# @param [
|
196
|
+
# @param [ Class, Module ] object The class or module the field is
|
197
|
+
# defined on.
|
190
198
|
#
|
191
199
|
# @since 3.0.0
|
192
|
-
def define_default_method(
|
193
|
-
|
194
|
-
doc.class.__send__(:define_method, default_name, default_val)
|
195
|
-
end
|
200
|
+
def define_default_method(object)
|
201
|
+
object.__send__(:define_method, default_name, default_val)
|
196
202
|
end
|
197
203
|
|
198
204
|
# Is the field included in the fields that were returned from the
|
@@ -243,7 +249,6 @@ module Mongoid
|
|
243
249
|
#
|
244
250
|
# @since 3.0.0
|
245
251
|
def evaluate_default_proc(doc)
|
246
|
-
define_default_method(doc)
|
247
252
|
serialize_default(doc.__send__(default_name))
|
248
253
|
end
|
249
254
|
|
data/lib/mongoid/hierarchy.rb
CHANGED
@@ -156,6 +156,7 @@ module Mongoid
|
|
156
156
|
def inherited(subclass)
|
157
157
|
super
|
158
158
|
@_type = nil
|
159
|
+
subclass.aliased_fields = aliased_fields.dup
|
159
160
|
subclass.fields = fields.dup
|
160
161
|
subclass.pre_processed_defaults = pre_processed_defaults.dup
|
161
162
|
subclass.post_processed_defaults = post_processed_defaults.dup
|
data/lib/mongoid/railtie.rb
CHANGED
@@ -118,11 +118,7 @@ module Rails
|
|
118
118
|
|
119
119
|
# Need to include the Mongoid identity map middleware.
|
120
120
|
initializer "include the identity map" do |app|
|
121
|
-
|
122
|
-
app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap::Passenger"
|
123
|
-
else
|
124
|
-
app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap"
|
125
|
-
end
|
121
|
+
app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap"
|
126
122
|
end
|
127
123
|
|
128
124
|
# Instantitate any registered observers after Rails initialization and
|
@@ -283,8 +283,8 @@ module Mongoid
|
|
283
283
|
#
|
284
284
|
# @since 3.0.0
|
285
285
|
def embed(name, metadata)
|
286
|
-
self.embedded_relations =
|
287
|
-
|
286
|
+
self.embedded_relations = embedded_relations.merge(name.to_s => metadata)
|
287
|
+
aliased_fields[name.to_s] = metadata.store_as if metadata.store_as
|
288
288
|
end
|
289
289
|
|
290
290
|
# Defines a field to be used as a foreign key in the relation and
|
data/lib/mongoid/version.rb
CHANGED
@@ -31,43 +31,7 @@ module Rack
|
|
31
31
|
#
|
32
32
|
# @since 2.1.0
|
33
33
|
def call(env)
|
34
|
-
|
35
|
-
response[2] = ::Rack::BodyProxy.new(response[2]) do
|
36
|
-
::Mongoid::IdentityMap.clear
|
37
|
-
end
|
38
|
-
response
|
39
|
-
end
|
40
|
-
|
41
|
-
# Passenger 3 does not execute the block provided to a Rack::BodyProxy
|
42
|
-
# so the identity map never gets cleared. Since there's no streaming
|
43
|
-
# support in it anyways we do not need the proxy functionality.
|
44
|
-
class Passenger
|
45
|
-
|
46
|
-
# Initialize the new middleware.
|
47
|
-
#
|
48
|
-
# @example Init the middleware.
|
49
|
-
# IdentityMap.new(app)
|
50
|
-
#
|
51
|
-
# @param [ Object ] app The application.
|
52
|
-
#
|
53
|
-
# @since 3.0.11
|
54
|
-
def initialize(app)
|
55
|
-
@app = app
|
56
|
-
end
|
57
|
-
|
58
|
-
# Make the request with the provided environment.
|
59
|
-
#
|
60
|
-
# @example Make the request.
|
61
|
-
# identity_map.call(env)
|
62
|
-
#
|
63
|
-
# @param [ Object ] env The environment.
|
64
|
-
#
|
65
|
-
# @return [ Array ] The status, headers, and response.
|
66
|
-
#
|
67
|
-
# @since 3.0.11
|
68
|
-
def call(env)
|
69
|
-
::Mongoid.unit_of_work { @app.call(env) }
|
70
|
-
end
|
34
|
+
::Mongoid.unit_of_work { @app.call(env) }
|
71
35
|
end
|
72
36
|
end
|
73
37
|
end
|
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: 3.0.
|
4
|
+
version: 3.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -352,7 +352,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
352
352
|
version: '0'
|
353
353
|
segments:
|
354
354
|
- 0
|
355
|
-
hash:
|
355
|
+
hash: -1846973672677676988
|
356
356
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
357
357
|
none: false
|
358
358
|
requirements:
|