mongoid 2.4.4 → 2.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +29 -1
- data/lib/config/locales/bg.yml +1 -0
- data/lib/config/locales/de.yml +1 -0
- data/lib/config/locales/en-GB.yml +1 -0
- data/lib/config/locales/en.yml +1 -0
- data/lib/config/locales/es.yml +1 -0
- data/lib/config/locales/fr.yml +1 -0
- data/lib/config/locales/hi.yml +1 -0
- data/lib/config/locales/hu.yml +1 -0
- data/lib/config/locales/id.yml +1 -0
- data/lib/config/locales/it.yml +1 -0
- data/lib/config/locales/ja.yml +1 -0
- data/lib/config/locales/kr.yml +1 -0
- data/lib/config/locales/nl.yml +1 -0
- data/lib/config/locales/pl.yml +1 -0
- data/lib/config/locales/pt-BR.yml +1 -0
- data/lib/config/locales/pt.yml +1 -0
- data/lib/config/locales/ro.yml +1 -0
- data/lib/config/locales/ru.yml +1 -0
- data/lib/config/locales/sv.yml +1 -0
- data/lib/config/locales/vi.yml +1 -0
- data/lib/config/locales/zh-CN.yml +1 -0
- data/lib/mongoid/callbacks.rb +3 -4
- data/lib/mongoid/contexts/enumerable.rb +2 -1
- data/lib/mongoid/document.rb +1 -1
- data/lib/mongoid/fields/internal/foreign_keys/array.rb +16 -11
- data/lib/mongoid/logger.rb +7 -1
- data/lib/mongoid/matchers/strategies.rb +6 -2
- data/lib/mongoid/serialization.rb +12 -3
- data/lib/mongoid/validations/presence.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/mongoid.rb +1 -1
- metadata +21 -21
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,35 @@
|
|
3
3
|
For instructions on upgrading to newer versions, visit
|
4
4
|
[mongoid.org](http://mongoid.org/docs/upgrading.html).
|
5
5
|
|
6
|
-
## 2.4.
|
6
|
+
## 2.4.5 (branch: 2.4.0-stable)
|
7
|
+
|
8
|
+
### Resolved Issues
|
9
|
+
|
10
|
+
* \#1751 Mongoid's logger now responds to level for Ruby logging API
|
11
|
+
compatibility.
|
12
|
+
|
13
|
+
* \#1744/#1750 Sorting works now for localized fields in embedded documents
|
14
|
+
using the criteria API. (Hans Hasselberg)
|
15
|
+
|
16
|
+
* \#1746 Presence validation now shows which locales were empty for
|
17
|
+
localized fields. (Cyril Mougel)
|
18
|
+
|
19
|
+
* \#1727 Allow dot notation in embedded criteria to work on both embeds one
|
20
|
+
and embeds many. (Lyle Underwood)
|
21
|
+
|
22
|
+
* \#1723 Initialize callbacks should cascade through children without needing
|
23
|
+
to determine if the child is changed.
|
24
|
+
|
25
|
+
* \#1715 Serializable hashes are now consistent on inclusion of embedded
|
26
|
+
documents per or post save.
|
27
|
+
|
28
|
+
* \#1713 Fixing === checks when comparing a class with an instance of a
|
29
|
+
subclass.
|
30
|
+
|
31
|
+
* \#1495 Callbacks no longer get the 'super called outside of method` errors on
|
32
|
+
busted 1.8.7 rubies.
|
33
|
+
|
34
|
+
## 2.4.4
|
7
35
|
|
8
36
|
### Resolved Issues
|
9
37
|
|
data/lib/config/locales/bg.yml
CHANGED
data/lib/config/locales/de.yml
CHANGED
data/lib/config/locales/en.yml
CHANGED
data/lib/config/locales/es.yml
CHANGED
data/lib/config/locales/fr.yml
CHANGED
data/lib/config/locales/hi.yml
CHANGED
data/lib/config/locales/hu.yml
CHANGED
data/lib/config/locales/id.yml
CHANGED
data/lib/config/locales/it.yml
CHANGED
data/lib/config/locales/ja.yml
CHANGED
data/lib/config/locales/kr.yml
CHANGED
data/lib/config/locales/nl.yml
CHANGED
data/lib/config/locales/pl.yml
CHANGED
data/lib/config/locales/pt.yml
CHANGED
data/lib/config/locales/ro.yml
CHANGED
data/lib/config/locales/ru.yml
CHANGED
data/lib/config/locales/sv.yml
CHANGED
data/lib/config/locales/vi.yml
CHANGED
data/lib/mongoid/callbacks.rb
CHANGED
@@ -39,9 +39,8 @@ module Mongoid #:nodoc:
|
|
39
39
|
#
|
40
40
|
# @since 2.3.0
|
41
41
|
def run_callbacks(kind, *args, &block)
|
42
|
-
run_cascading_callbacks(cascadable_children(kind), kind, *args)
|
43
|
-
|
44
|
-
end
|
42
|
+
run_cascading_callbacks(cascadable_children(kind), kind, *args) {}
|
43
|
+
super(kind, *args, &block)
|
45
44
|
end
|
46
45
|
|
47
46
|
private
|
@@ -106,7 +105,7 @@ module Mongoid #:nodoc:
|
|
106
105
|
#
|
107
106
|
# @since 2.3.0
|
108
107
|
def cascadable_child?(kind, child)
|
109
|
-
[ :create, :destroy ].include?(kind) || child.changed? || child.new_record?
|
108
|
+
[ :create, :destroy, :initialize ].include?(kind) || child.changed? || child.new_record?
|
110
109
|
end
|
111
110
|
|
112
111
|
# Get the name of the callback that the child should fire. This changes
|
@@ -303,7 +303,8 @@ module Mongoid #:nodoc:
|
|
303
303
|
return documents if options[:sort].blank?
|
304
304
|
documents.sort_by do |document|
|
305
305
|
options[:sort].map do |key, direction|
|
306
|
-
|
306
|
+
key = key.to_s.gsub(/(.*)\.#{I18n.locale}$/, '\1')
|
307
|
+
Sort.new(document.send(key), direction)
|
307
308
|
end
|
308
309
|
end
|
309
310
|
end
|
data/lib/mongoid/document.rb
CHANGED
@@ -276,7 +276,7 @@ module Mongoid #:nodoc:
|
|
276
276
|
#
|
277
277
|
# @since 2.0.0.rc.4
|
278
278
|
def ===(other)
|
279
|
-
|
279
|
+
other.is_a?(Class) ? self == other : other.is_a?(self)
|
280
280
|
end
|
281
281
|
|
282
282
|
# Instantiate a new object, only when loaded from the database or when
|
@@ -23,17 +23,22 @@ module Mongoid #:nodoc:
|
|
23
23
|
# @param [ Array ] old The old elements getting removed.
|
24
24
|
#
|
25
25
|
# @since 2.4.0
|
26
|
-
def add_atomic_changes(document, name, key, mods,
|
27
|
-
|
28
|
-
|
29
|
-
if old.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
elsif
|
36
|
-
|
26
|
+
def add_atomic_changes(document, name, key, mods, new_elements, old_elements)
|
27
|
+
old = (old_elements || [])
|
28
|
+
new = (new_elements || [])
|
29
|
+
if new.length > old.length
|
30
|
+
if new.first(old.length) == old
|
31
|
+
document.atomic_array_add_to_sets[key] = new.drop(old.length)
|
32
|
+
else
|
33
|
+
mods[key] = document.attributes[name]
|
34
|
+
end
|
35
|
+
elsif new.length < old.length
|
36
|
+
pulls = old - new
|
37
|
+
if new == old - pulls
|
38
|
+
document.atomic_array_pulls[key] = pulls
|
39
|
+
else
|
40
|
+
mods[key] = document.attributes[name]
|
41
|
+
end
|
37
42
|
elsif new != old
|
38
43
|
mods[key] = document.attributes[name]
|
39
44
|
end
|
data/lib/mongoid/logger.rb
CHANGED
@@ -4,7 +4,13 @@ module Mongoid #:nodoc:
|
|
4
4
|
# The Mongoid logger which wraps some other ruby compliant logger class.
|
5
5
|
class Logger
|
6
6
|
|
7
|
-
delegate
|
7
|
+
delegate \
|
8
|
+
:info,
|
9
|
+
:debug,
|
10
|
+
:error,
|
11
|
+
:fatal,
|
12
|
+
:level,
|
13
|
+
:unknown, :to => :logger, :allow_nil => true
|
8
14
|
|
9
15
|
# Emit a warning log message.
|
10
16
|
#
|
@@ -81,8 +81,12 @@ module Mongoid #:nodoc:
|
|
81
81
|
# @since 2.2.1
|
82
82
|
def extract_attribute(document, key)
|
83
83
|
if (key_string = key.to_s) =~ /.+\..+/
|
84
|
-
key_string.split('.').inject(document.attributes) do |
|
85
|
-
|
84
|
+
key_string.split('.').inject(document.attributes) do |_attribs, _key|
|
85
|
+
if _attribs.is_a?(::Array)
|
86
|
+
_attribs.map { |doc| doc.try(:[], _key) }
|
87
|
+
else
|
88
|
+
_attribs.try(:[], _key)
|
89
|
+
end
|
86
90
|
end
|
87
91
|
else
|
88
92
|
document.attributes[key_string]
|
@@ -34,15 +34,24 @@ module Mongoid # :nodoc:
|
|
34
34
|
except |= ['_type'] unless Mongoid.include_type_for_serialization
|
35
35
|
|
36
36
|
field_names = fields.keys.map { |field| field.to_s }
|
37
|
-
attribute_names = (
|
37
|
+
attribute_names = (as_document.keys + field_names).sort
|
38
38
|
if only.any?
|
39
39
|
attribute_names &= only
|
40
40
|
elsif except.any?
|
41
41
|
attribute_names -= except
|
42
42
|
end
|
43
43
|
|
44
|
-
method_names = Array.wrap(options[:methods]).map
|
45
|
-
|
44
|
+
method_names = Array.wrap(options[:methods]).map do |name|
|
45
|
+
name.to_s if respond_to?(name)
|
46
|
+
end.compact
|
47
|
+
|
48
|
+
{}.tap do |attrs|
|
49
|
+
attribute_names.each do |name|
|
50
|
+
attrs[name] = attributes[name]
|
51
|
+
end
|
52
|
+
method_names.each do |name|
|
53
|
+
attrs[name] = send(name)
|
54
|
+
end
|
46
55
|
serialize_relations(attrs, options) if options[:include]
|
47
56
|
end
|
48
57
|
end
|
@@ -29,7 +29,7 @@ module Mongoid #:nodoc:
|
|
29
29
|
field = document.fields[attribute.to_s]
|
30
30
|
if field && field.localized? && !value.blank?
|
31
31
|
value.each_pair do |locale, value|
|
32
|
-
document.errors.add(attribute, :
|
32
|
+
document.errors.add(attribute, :blank_on_locale, options.merge(:in_locale => locale)) if value.blank?
|
33
33
|
end
|
34
34
|
else
|
35
35
|
document.errors.add(attribute, :blank, options) if value.blank?
|
data/lib/mongoid/version.rb
CHANGED
data/lib/rails/mongoid.rb
CHANGED
@@ -90,7 +90,7 @@ module Rails #:nodoc:
|
|
90
90
|
parts = model_path.map { |path| path.camelize }
|
91
91
|
name = parts.join("::")
|
92
92
|
klass = name.constantize
|
93
|
-
rescue NameError => e
|
93
|
+
rescue NameError, LoadError => e
|
94
94
|
logger.info("Attempted to constantize #{name}, trying without namespacing.")
|
95
95
|
klass = parts.last.constantize
|
96
96
|
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: 2.4.
|
4
|
+
version: 2.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70356497238660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70356497238660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tzinfo
|
27
|
-
requirement: &
|
27
|
+
requirement: &70356497237480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.3.22
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70356497237480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mongo
|
38
|
-
requirement: &
|
38
|
+
requirement: &70356497236500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.3'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70356497236500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &70356497234880 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 3.5.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70356497234880
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bson_ext
|
60
|
-
requirement: &
|
60
|
+
requirement: &70356497233800 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70356497233800
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &70356497083440 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.10'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70356497083440
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70356497082860 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.6'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70356497082860
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard-rspec
|
93
|
-
requirement: &
|
93
|
+
requirement: &70356497081920 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0.6'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70356497081920
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: ammeter
|
104
|
-
requirement: &
|
104
|
+
requirement: &70356497081280 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 0.1.3
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70356497081280
|
113
113
|
description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
|
114
114
|
in Ruby.
|
115
115
|
email:
|
@@ -414,7 +414,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
414
414
|
version: '0'
|
415
415
|
segments:
|
416
416
|
- 0
|
417
|
-
hash:
|
417
|
+
hash: 2742246905926364196
|
418
418
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
419
419
|
none: false
|
420
420
|
requirements:
|