mongoid 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/lib/mongoid/callbacks.rb +20 -25
- data/lib/mongoid/relations/referenced/many.rb +7 -4
- data/lib/mongoid/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
For instructions on upgrading to newer versions, visit
|
4
4
|
[mongoid.org](http://mongoid.org/docs/upgrading.html).
|
5
5
|
|
6
|
+
## 2.5.1
|
7
|
+
|
8
|
+
### Resolved Issues
|
9
|
+
|
10
|
+
* \#2492 Backport cascading callbacks performance and memory fixes from
|
11
|
+
3.0.0-stable.
|
12
|
+
|
13
|
+
* \#2464 Backport the nested attributes fix for keeping many relations in
|
14
|
+
memory when updating attributes. (Chris Thompson)
|
15
|
+
|
6
16
|
## 2.5.0
|
7
17
|
|
8
18
|
### New Features
|
data/lib/mongoid/callbacks.rb
CHANGED
@@ -23,6 +23,20 @@ module Mongoid #:nodoc:
|
|
23
23
|
define_model_callbacks :create, :destroy, :save, :update
|
24
24
|
end
|
25
25
|
|
26
|
+
# Is the provided type of callback executable by this document?
|
27
|
+
#
|
28
|
+
# @example Is the callback executable?
|
29
|
+
# document.callback_executable?(:save)
|
30
|
+
#
|
31
|
+
# @param [ Symbol ] kin The type of callback.
|
32
|
+
#
|
33
|
+
# @return [ true, false ] If the callback can be executed.
|
34
|
+
#
|
35
|
+
# @since 2.5.1
|
36
|
+
def callback_executable?(kind)
|
37
|
+
respond_to?("_#{kind}_callbacks")
|
38
|
+
end
|
39
|
+
|
26
40
|
# Run the callbacks for the document. This overrides active support's
|
27
41
|
# functionality to cascade callbacks to embedded documents that have been
|
28
42
|
# flagged as such.
|
@@ -39,35 +53,16 @@ module Mongoid #:nodoc:
|
|
39
53
|
#
|
40
54
|
# @since 2.3.0
|
41
55
|
def run_callbacks(kind, *args, &block)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# Execute the callbacks, including all children that have cascade callbacks
|
49
|
-
# set to true.
|
50
|
-
#
|
51
|
-
# @example Run the cascading callbacks.
|
52
|
-
# document.run_cascading_callbacks([], :update)
|
53
|
-
#
|
54
|
-
# @param [ Array<Document> ] children The cascading children.
|
55
|
-
# @param [ Symbol ] kind The callback type.
|
56
|
-
# @param [ Array ] args The options.
|
57
|
-
#
|
58
|
-
# @since 2.3.0
|
59
|
-
def run_cascading_callbacks(children, kind, *args, &block)
|
60
|
-
if child = children.pop
|
61
|
-
run_cascading_callbacks(children, kind, *args) do
|
62
|
-
child.run_callbacks(child_callback_type(kind, child), *args) do
|
63
|
-
block.call
|
64
|
-
end
|
56
|
+
cascadable_children(kind).each do |child|
|
57
|
+
unless child.run_callbacks(child_callback_type(kind, child), *args)
|
58
|
+
return false
|
65
59
|
end
|
66
|
-
else
|
67
|
-
block.call
|
68
60
|
end
|
61
|
+
callback_executable?(kind) ? super(kind, *args, &block) : true
|
69
62
|
end
|
70
63
|
|
64
|
+
private
|
65
|
+
|
71
66
|
# Get all the child embedded documents that are flagged as cascadable.
|
72
67
|
#
|
73
68
|
# @example Get all the cascading children.
|
@@ -239,15 +239,18 @@ module Mongoid #:nodoc:
|
|
239
239
|
# @example Conditionally find the last document.
|
240
240
|
# person.posts.find(:last, :conditions => { :title => "Sir" })
|
241
241
|
#
|
242
|
-
# @
|
243
|
-
#
|
244
|
-
#
|
242
|
+
# @note This will keep matching documents in memory for iteration
|
243
|
+
# later.
|
244
|
+
#
|
245
|
+
# @param [ Moped::BSON::ObjectId, Array<Moped::BSON::ObjectId> ] arg The ids.
|
245
246
|
#
|
246
247
|
# @return [ Document, Criteria ] The matching document(s).
|
247
248
|
#
|
248
249
|
# @since 2.0.0.beta.1
|
249
250
|
def find(*args)
|
250
|
-
criteria.find(*args)
|
251
|
+
matching = criteria.find(*args)
|
252
|
+
Array(matching).each { |doc| target.push(doc) }
|
253
|
+
matching
|
251
254
|
end
|
252
255
|
|
253
256
|
# Instantiate a new references_many relation. Will set the foreign key
|
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.5.
|
4
|
+
version: 2.5.1
|
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-
|
12
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -429,7 +429,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
429
429
|
version: '0'
|
430
430
|
segments:
|
431
431
|
- 0
|
432
|
-
hash:
|
432
|
+
hash: -2098337333332267571
|
433
433
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
434
434
|
none: false
|
435
435
|
requirements:
|