active_type 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf0c969c67a643824d8195b0fe7ce13215660e7
|
4
|
+
data.tar.gz: c2581b3a4733b6f03f68809beb919586e535d6c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 148518ebba3e5f54bb207290c38a7e29d3b842022faa579df939902e10fb5450413ef71a8f467d2d639a9e9cc7415ed2df6fcbf5fb7ae1fb7c95695426c2d062
|
7
|
+
data.tar.gz: 10d6b1f5441d01bc2fa7d8c8c002d5a7ff398cf186c352c3c6be80471055015427ec51ddfeefd4155b26105d6605f8e6bcf2d78b5a4fe17edcabfd5b60c0f170
|
data/.travis.yml
CHANGED
@@ -54,3 +54,9 @@ matrix:
|
|
54
54
|
gemfile: gemfiles/Gemfile.3.2.mysql2
|
55
55
|
- rvm: "2.2.4"
|
56
56
|
gemfile: gemfiles/Gemfile.4.1.sqlite3
|
57
|
+
install:
|
58
|
+
# Replace default Travis CI bundler script with a version that doesn't
|
59
|
+
# explode when lockfile doesn't match recently bumped version
|
60
|
+
- gem uninstall bundler -x -I
|
61
|
+
- gem install bundler --version='=1.12.5'
|
62
|
+
- bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
data/README.md
CHANGED
@@ -308,6 +308,13 @@ Supported options for `nests_many` / `nests_one` are:
|
|
308
308
|
nests_many :documents, default: proc { Documents.all }
|
309
309
|
```
|
310
310
|
|
311
|
+
Options supported exclusively by `nests_many` are:
|
312
|
+
|
313
|
+
- `index_errors`
|
314
|
+
|
315
|
+
Use a boolean to get indexed errors on related records. In Rails 5 you can make it global with
|
316
|
+
`config.active_record.index_nested_attribute_errors = true`.
|
317
|
+
|
311
318
|
|
312
319
|
Casting records or relations
|
313
320
|
----------------------------
|
@@ -9,13 +9,18 @@ module ActiveType
|
|
9
9
|
class Association
|
10
10
|
|
11
11
|
def initialize(owner, target_name, options = {})
|
12
|
-
options.assert_valid_keys(
|
12
|
+
options.assert_valid_keys(*valid_options)
|
13
13
|
|
14
14
|
@owner = owner
|
15
15
|
@target_name = target_name.to_sym
|
16
16
|
@allow_destroy = options.fetch(:allow_destroy, false)
|
17
17
|
@reject_if = options.delete(:reject_if)
|
18
18
|
@options = options.dup
|
19
|
+
@index_errors = if ActiveRecord::VERSION::MAJOR < 5
|
20
|
+
@options[:index_errors]
|
21
|
+
else
|
22
|
+
@options[:index_errors] || ActiveRecord::Base.index_nested_attribute_errors
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
def assign_attributes(parent, attributes)
|
@@ -36,10 +41,10 @@ module ActiveType
|
|
36
41
|
end
|
37
42
|
|
38
43
|
def validate(parent)
|
39
|
-
changed_children(parent).
|
44
|
+
changed_children(parent).each_with_index do |child, index|
|
40
45
|
unless child.valid?
|
41
46
|
child.errors.each do |attribute, message|
|
42
|
-
attribute = "#{@target_name}.#{attribute}"
|
47
|
+
attribute = @index_errors ? "#{@target_name}[#{index}].#{attribute}" : "#{@target_name}.#{attribute}"
|
43
48
|
parent.errors[attribute] << message
|
44
49
|
parent.errors[attribute].uniq!
|
45
50
|
end
|
@@ -122,6 +127,10 @@ module ActiveType
|
|
122
127
|
result
|
123
128
|
end
|
124
129
|
|
130
|
+
def valid_options
|
131
|
+
[:build_scope, :find_scope, :scope, :allow_destroy, :reject_if]
|
132
|
+
end
|
133
|
+
|
125
134
|
end
|
126
135
|
|
127
136
|
end
|
data/lib/active_type/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Kraze
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04-
|
12
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|