mongoid 2.4.10 → 2.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +17 -0
- data/Rakefile +0 -9
- data/lib/config/locales/bg.yml +1 -1
- data/lib/config/locales/de.yml +1 -1
- data/lib/config/locales/en-GB.yml +1 -1
- data/lib/config/locales/es.yml +1 -1
- data/lib/config/locales/fr.yml +1 -1
- data/lib/config/locales/hi.yml +1 -1
- data/lib/config/locales/hu.yml +1 -1
- data/lib/config/locales/id.yml +1 -1
- data/lib/config/locales/it.yml +1 -1
- data/lib/config/locales/ja.yml +1 -1
- data/lib/config/locales/kr.yml +1 -1
- data/lib/config/locales/nl.yml +1 -1
- data/lib/config/locales/pl.yml +1 -1
- data/lib/config/locales/pt-BR.yml +1 -1
- data/lib/config/locales/pt.yml +1 -1
- data/lib/config/locales/ro.yml +1 -1
- data/lib/config/locales/ru.yml +1 -1
- data/lib/config/locales/sv.yml +1 -1
- data/lib/config/locales/vi.yml +1 -1
- data/lib/config/locales/zh-CN.yml +1 -1
- data/lib/mongoid/components.rb +1 -1
- data/lib/mongoid/config/environment.rb +3 -1
- data/lib/mongoid/copyable.rb +32 -1
- data/lib/mongoid/criterion/exclusion.rb +3 -1
- data/lib/mongoid/relations/metadata.rb +20 -1
- data/lib/mongoid/serialization.rb +5 -3
- data/lib/mongoid/validations.rb +1 -1
- data/lib/mongoid/validations/presence.rb +4 -0
- data/lib/mongoid/version.rb +1 -1
- metadata +11 -43
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,23 @@ For instructions on upgrading to newer versions, visit
|
|
7
7
|
|
8
8
|
### Resolved Issues
|
9
9
|
|
10
|
+
* This release forces a cap on the mongo driver version at 1.6.2 due to
|
11
|
+
changes in the `Mongo::Connection.from_uri` API not allowing valid
|
12
|
+
connection options anymore.
|
13
|
+
|
14
|
+
* \#2040 Fixed bad interpolation for locale presence validation.
|
15
|
+
|
16
|
+
* \#2038 Allow inverse relations to be determined by foreign keys alone
|
17
|
+
if defined on both sides, not just an inverse_of declaration.
|
18
|
+
|
19
|
+
* \#2023 Allow serilialization of dynamic types that conflict with core
|
20
|
+
Ruby methods to still be serialized.
|
21
|
+
|
22
|
+
* \#2008 Presence validation should hit the db to check validity if the
|
23
|
+
relation in memory is blank.
|
24
|
+
|
25
|
+
* \#2006 Allow excluding only the _id field post execution of an #only call.
|
26
|
+
|
10
27
|
## 2.4.10
|
11
28
|
|
12
29
|
### Resolved Issues
|
data/Rakefile
CHANGED
@@ -2,7 +2,6 @@ require "bundler"
|
|
2
2
|
Bundler.setup
|
3
3
|
|
4
4
|
require "rake"
|
5
|
-
require "rdoc/task"
|
6
5
|
require "rspec"
|
7
6
|
require "rspec/core/rake_task"
|
8
7
|
|
@@ -37,13 +36,5 @@ RSpec::Core::RakeTask.new('spec:progress') do |spec|
|
|
37
36
|
spec.pattern = "spec/**/*_spec.rb"
|
38
37
|
end
|
39
38
|
|
40
|
-
RDoc::Task.new do |rdoc|
|
41
|
-
rdoc.rdoc_dir = "rdoc"
|
42
|
-
rdoc.title = "mongoid #{Mongoid::VERSION}"
|
43
|
-
rdoc.rdoc_files.include("README*")
|
44
|
-
rdoc.rdoc_files.include("CHANGELOG*")
|
45
|
-
rdoc.rdoc_files.include("lib/**/*.rb")
|
46
|
-
end
|
47
|
-
|
48
39
|
task :spec => [ "spec:functional", "spec:unit" ]
|
49
40
|
task :default => :spec
|
data/lib/config/locales/bg.yml
CHANGED
data/lib/config/locales/de.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/components.rb
CHANGED
@@ -22,7 +22,6 @@ module Mongoid #:nodoc
|
|
22
22
|
include Mongoid::Dirty
|
23
23
|
include Mongoid::Attributes
|
24
24
|
include Mongoid::Collections
|
25
|
-
include Mongoid::Copyable
|
26
25
|
include Mongoid::DefaultScope
|
27
26
|
include Mongoid::Extras
|
28
27
|
include Mongoid::Fields
|
@@ -45,6 +44,7 @@ module Mongoid #:nodoc
|
|
45
44
|
include Mongoid::Timestamps::Timeless
|
46
45
|
include Mongoid::Validations
|
47
46
|
include Mongoid::Callbacks
|
47
|
+
include Mongoid::Copyable
|
48
48
|
include Mongoid::MultiDatabase
|
49
49
|
|
50
50
|
MODULES = [
|
@@ -8,11 +8,13 @@ module Mongoid #:nodoc
|
|
8
8
|
|
9
9
|
# Get the name of the environment that we are running under. This first
|
10
10
|
# looks for Rails, then Sinatra, then a RACK_ENV environment variable,
|
11
|
-
# and if none of those are found
|
11
|
+
# and if none of those are found raises an error.
|
12
12
|
#
|
13
13
|
# @example Get the env name.
|
14
14
|
# Environment.env_name
|
15
15
|
#
|
16
|
+
# @raise [ Errors::NoEnvironment ] If no environment was set.
|
17
|
+
#
|
16
18
|
# @return [ String ] The name of the current environment.
|
17
19
|
#
|
18
20
|
# @since 2.3.0
|
data/lib/mongoid/copyable.rb
CHANGED
@@ -23,13 +23,44 @@ module Mongoid #:nodoc:
|
|
23
23
|
# @example Clone the document.
|
24
24
|
# document.clone
|
25
25
|
#
|
26
|
+
# @param [ Document ] other The document getting cloned.
|
27
|
+
#
|
28
|
+
# @return [ Document ] The new document.
|
29
|
+
def initialize_copy(other)
|
30
|
+
__copy__(other)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Clone or dup the current +Document+. This will return all attributes with
|
34
|
+
# the exception of the document's id and versions, and will reset all the
|
35
|
+
# instance variables.
|
36
|
+
#
|
37
|
+
# This clone also includes embedded documents.
|
38
|
+
#
|
26
39
|
# @example Dup the document.
|
27
40
|
# document.dup
|
28
41
|
#
|
29
42
|
# @param [ Document ] other The document getting cloned.
|
30
43
|
#
|
31
44
|
# @return [ Document ] The new document.
|
32
|
-
def
|
45
|
+
def initialize_dup(other)
|
46
|
+
__copy__(other)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Handle the copy of the object.
|
52
|
+
#
|
53
|
+
# @api private
|
54
|
+
#
|
55
|
+
# @example Copy the object.
|
56
|
+
# document.__copy__(other)
|
57
|
+
#
|
58
|
+
# @param [ Document ] other The other document.
|
59
|
+
#
|
60
|
+
# @return [ Document ] self.
|
61
|
+
#
|
62
|
+
# @since 3.0.0
|
63
|
+
def __copy__(other)
|
33
64
|
other.as_document
|
34
65
|
instance_variables.each { |name| remove_instance_variable(name) }
|
35
66
|
COPYABLES.each do |name|
|
@@ -96,7 +96,9 @@ module Mongoid #:nodoc:
|
|
96
96
|
def without(*args)
|
97
97
|
clone.tap do |crit|
|
98
98
|
if args.any?
|
99
|
-
|
99
|
+
unless args == [ :id ] || args == [ :_id ]
|
100
|
+
crit.options[:fields] = {}
|
101
|
+
end
|
100
102
|
args.flatten.each do |f|
|
101
103
|
crit.options[:fields][f] = 0
|
102
104
|
end
|
@@ -861,7 +861,7 @@ module Mongoid # :nodoc:
|
|
861
861
|
#
|
862
862
|
# @since 2.0.0.rc.1
|
863
863
|
def determine_inverse_relation
|
864
|
-
default = klass.relations[inverse_klass.name.underscore]
|
864
|
+
default = foreign_key_match || klass.relations[inverse_klass.name.underscore]
|
865
865
|
return default.name if default
|
866
866
|
klass.relations.each_pair do |key, meta|
|
867
867
|
next if meta.versioned? || meta.name == name
|
@@ -872,6 +872,25 @@ module Mongoid # :nodoc:
|
|
872
872
|
return nil
|
873
873
|
end
|
874
874
|
|
875
|
+
# Return metadata where the foreign key matches the foreign key on this
|
876
|
+
# relation.
|
877
|
+
#
|
878
|
+
# @api private
|
879
|
+
#
|
880
|
+
# @example Return a foreign key match.
|
881
|
+
# meta.foreign_key_match
|
882
|
+
#
|
883
|
+
# @return [ Metadata ] A match, if any.
|
884
|
+
#
|
885
|
+
# @since 2.4.11
|
886
|
+
def foreign_key_match
|
887
|
+
if fk = self[:foreign_key]
|
888
|
+
klass.relations.values.detect do |meta|
|
889
|
+
fk == meta.foreign_key if meta.stores_foreign_key?
|
890
|
+
end
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
875
894
|
# Determine the key for the relation in the attributes.
|
876
895
|
#
|
877
896
|
# @example Get the key.
|
@@ -47,11 +47,13 @@ module Mongoid # :nodoc:
|
|
47
47
|
|
48
48
|
{}.tap do |attrs|
|
49
49
|
(attribute_names + method_names).each do |name|
|
50
|
-
value = send(name)
|
51
50
|
if relations.has_key?(name)
|
52
|
-
|
51
|
+
value = send(name)
|
52
|
+
attrs[name] = value ? value.serializable_hash(options) : nil
|
53
|
+
elsif attribute_names.include?(name) && !fields.has_key?(name)
|
54
|
+
attrs[name] = read_attribute(name)
|
53
55
|
else
|
54
|
-
attrs[name] =
|
56
|
+
attrs[name] = send(name)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
serialize_relations(attrs, options) if options[:include]
|
data/lib/mongoid/validations.rb
CHANGED
@@ -31,6 +31,10 @@ module Mongoid #:nodoc:
|
|
31
31
|
value.each_pair do |locale, value|
|
32
32
|
document.errors.add(attribute, :blank_on_locale, options.merge(:location => locale)) if value.blank?
|
33
33
|
end
|
34
|
+
elsif document.relations.has_key?(attribute.to_s)
|
35
|
+
if value.blank? && document.send(attribute).blank?
|
36
|
+
document.errors.add(attribute, :blank, options)
|
37
|
+
end
|
34
38
|
else
|
35
39
|
document.errors.add(attribute, :blank, options) if value.blank?
|
36
40
|
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.4.
|
4
|
+
version: 2.4.11
|
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-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -48,33 +48,17 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - <=
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 1.6.2
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.3'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rdoc
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 3.5.0
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
59
|
+
- - <=
|
76
60
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
61
|
+
version: 1.6.2
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
63
|
name: bson_ext
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +98,7 @@ dependencies:
|
|
114
98
|
requirements:
|
115
99
|
- - ~>
|
116
100
|
- !ruby/object:Gem::Version
|
117
|
-
version: '2.
|
101
|
+
version: '2.10'
|
118
102
|
type: :development
|
119
103
|
prerelease: false
|
120
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +106,7 @@ dependencies:
|
|
122
106
|
requirements:
|
123
107
|
- - ~>
|
124
108
|
- !ruby/object:Gem::Version
|
125
|
-
version: '2.
|
109
|
+
version: '2.10'
|
126
110
|
- !ruby/object:Gem::Dependency
|
127
111
|
name: guard-rspec
|
128
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,23 +114,7 @@ dependencies:
|
|
130
114
|
requirements:
|
131
115
|
- - ~>
|
132
116
|
- !ruby/object:Gem::Version
|
133
|
-
version: '0.
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0.6'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: ammeter
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 0.1.3
|
117
|
+
version: '0.7'
|
150
118
|
type: :development
|
151
119
|
prerelease: false
|
152
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +122,7 @@ dependencies:
|
|
154
122
|
requirements:
|
155
123
|
- - ~>
|
156
124
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.
|
125
|
+
version: '0.7'
|
158
126
|
description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
|
159
127
|
in Ruby.
|
160
128
|
email:
|
@@ -461,7 +429,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
461
429
|
version: '0'
|
462
430
|
segments:
|
463
431
|
- 0
|
464
|
-
hash:
|
432
|
+
hash: 4531209101708295137
|
465
433
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
466
434
|
none: false
|
467
435
|
requirements:
|