mongoid 5.0.0.rc0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/config/options.rb +1 -1
- data/lib/mongoid/errors/mongoid_error.rb +8 -6
- data/lib/mongoid/railtie.rb +0 -1
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +3 -2
- data/lib/mongoid/relations/metadata.rb +14 -0
- data/lib/mongoid/version.rb +1 -1
- data/spec/config/mongoid.yml +1 -1
- data/spec/mongoid/config_spec.rb +1 -1
- data/spec/mongoid/errors/mongoid_error_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add22f9a2555b543be72f205bad6bc0baa3f00c5
|
4
|
+
data.tar.gz: e5e3472e31f1f826a4ad7cd0e2607aeef72a4adc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6349535d149183db9330fa3469e8ad25a119e3bb78545046f0cf44e1de7c75be8ca3f1785aeb387856d2ab7d50e079a17dc3328c3a8fe4d26cf1332923a3a994
|
7
|
+
data.tar.gz: 78fecf90c0308eb831ace2022c9acd4ac817b3b4080332a8207c31db0aeafd1d683b4ce30257e99bfe20e1745215d9789d6c88e5a99c05e847d76f77e5f429f9
|
@@ -20,7 +20,7 @@ module Mongoid
|
|
20
20
|
# Define a configuration option with a default.
|
21
21
|
#
|
22
22
|
# @example Define the option.
|
23
|
-
# Options.option(:
|
23
|
+
# Options.option(:logger, :default => Logger.new($stdout, :warn))
|
24
24
|
#
|
25
25
|
# @param [ Symbol ] name The name of the configuration option.
|
26
26
|
# @param [ Hash ] options Extras for the option.
|
@@ -7,6 +7,8 @@ module Mongoid
|
|
7
7
|
# translating the messages.
|
8
8
|
class MongoidError < StandardError
|
9
9
|
|
10
|
+
attr_reader :problem, :summary, :resolution
|
11
|
+
|
10
12
|
BASE_KEY = "mongoid.errors.messages"
|
11
13
|
|
12
14
|
# Compose the message.
|
@@ -18,9 +20,9 @@ module Mongoid
|
|
18
20
|
#
|
19
21
|
# @since 3.0.0
|
20
22
|
def compose_message(key, attributes)
|
21
|
-
@problem =
|
22
|
-
@summary =
|
23
|
-
@resolution =
|
23
|
+
@problem = translate_problem(key, attributes)
|
24
|
+
@summary = translate_summary(key, attributes)
|
25
|
+
@resolution = translate_resolution(key, attributes)
|
24
26
|
@problem_title = translate("message_title", {})
|
25
27
|
@summary_title = translate("summary_title", {})
|
26
28
|
@resolution_title = translate("resolution_title", {})
|
@@ -58,7 +60,7 @@ module Mongoid
|
|
58
60
|
# @return [ String ] The problem.
|
59
61
|
#
|
60
62
|
# @since 3.0.0
|
61
|
-
def
|
63
|
+
def translate_problem(key, attributes)
|
62
64
|
translate("#{key}.message", attributes)
|
63
65
|
end
|
64
66
|
|
@@ -73,7 +75,7 @@ module Mongoid
|
|
73
75
|
# @return [ String ] The summary.
|
74
76
|
#
|
75
77
|
# @since 3.0.0
|
76
|
-
def
|
78
|
+
def translate_summary(key, attributes)
|
77
79
|
translate("#{key}.summary", attributes)
|
78
80
|
end
|
79
81
|
|
@@ -88,7 +90,7 @@ module Mongoid
|
|
88
90
|
# @return [ String ] The resolution.
|
89
91
|
#
|
90
92
|
# @since 3.0.0
|
91
|
-
def
|
93
|
+
def translate_resolution(key, attributes)
|
92
94
|
translate("#{key}.resolution", attributes)
|
93
95
|
end
|
94
96
|
end
|
data/lib/mongoid/railtie.rb
CHANGED
@@ -20,8 +20,9 @@ module Mongoid
|
|
20
20
|
binding do
|
21
21
|
inverse_keys = doc.you_must(metadata.inverse_foreign_key)
|
22
22
|
if inverse_keys
|
23
|
-
|
24
|
-
|
23
|
+
record_id = inverse_record_id(doc)
|
24
|
+
unless inverse_keys.include?(record_id)
|
25
|
+
doc.you_must(metadata.inverse_foreign_key_setter, inverse_keys.push(record_id))
|
25
26
|
end
|
26
27
|
doc.reset_relation_criteria(metadata.inverse)
|
27
28
|
end
|
@@ -459,6 +459,20 @@ module Mongoid
|
|
459
459
|
@inverse_foreign_key ||= determine_inverse_foreign_key
|
460
460
|
end
|
461
461
|
|
462
|
+
# Used for relational many to many only. This determines the name of the
|
463
|
+
# foreign key field setter on the inverse side of the relation, since in this
|
464
|
+
# case there are keys on both sides.
|
465
|
+
#
|
466
|
+
# @example Find the inverse foreign key setter.
|
467
|
+
# metadata.inverse_foreign_key_setter
|
468
|
+
#
|
469
|
+
# @return [ String ] The foreign key setter on the inverse.
|
470
|
+
#
|
471
|
+
# @since 2.0.0.rc.1
|
472
|
+
def inverse_foreign_key_setter
|
473
|
+
@inverse_foreign_key_setter ||= "#{inverse_foreign_key}="
|
474
|
+
end
|
475
|
+
|
462
476
|
# Returns the inverse class of the proxied relation.
|
463
477
|
#
|
464
478
|
# @example Get the inverse class.
|
data/lib/mongoid/version.rb
CHANGED
data/spec/config/mongoid.yml
CHANGED
data/spec/mongoid/config_spec.rb
CHANGED
@@ -23,15 +23,15 @@ describe Mongoid::Errors::MongoidError do
|
|
23
23
|
describe "#compose_message" do
|
24
24
|
|
25
25
|
it "sets ivar problem" do
|
26
|
-
expect(error.
|
26
|
+
expect(error.problem).to be
|
27
27
|
end
|
28
28
|
|
29
29
|
it "sets ivar summary" do
|
30
|
-
expect(error.
|
30
|
+
expect(error.summary).to be
|
31
31
|
end
|
32
32
|
|
33
33
|
it "sets ivar resolution" do
|
34
|
-
expect(error.
|
34
|
+
expect(error.resolution).to be
|
35
35
|
end
|
36
36
|
|
37
37
|
it "sets ivar problem_title" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Durran Jordan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: mongo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.1
|
47
|
+
version: '2.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.1
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: origin
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|