store_model 0.2.0 → 0.3.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 917f6d81bda1120cd7801117957d7ccd65e16214816dcac19176852abd54a46a
|
4
|
+
data.tar.gz: 682125c5da079cc5f9b996020d301a89c2c066206c202d88e790c04cf43b22c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61dfaf89ef4bb1f712d8e7ae1210d52d97de8d684e98555ab4a51bb93d2a2e28a7634d160bf3dbc3b902f72a4ada384441b838fc14cff107efe0030f2a4c1bd9
|
7
|
+
data.tar.gz: 23f0572124d1749cadef51db9a992179c427d9e4e7adec3547305efd35ba6a47fe06bb613a758fcd956570a49f830e387301f373e961a92ea9d05d2fc92b7f26
|
data/README.md
CHANGED
@@ -140,6 +140,8 @@ You can change the global behavior using `StoreModel.config`:
|
|
140
140
|
StoreModel.config.merge_errors = true
|
141
141
|
```
|
142
142
|
|
143
|
+
> Heads up! Due to the [changes](https://github.com/rails/rails/pull/32313) of error internals in Rails >= 6.1 it's impossible to add an error with a key that does not have a corresponding attribute with the same name. Because of that, behavior of `merge_error` strategy will be different - all errors are going to be placed under the attribute name (`{ configuration: ["Color can't be blank"] }` instead of `{ color: ["can't be blank"] }`).
|
144
|
+
|
143
145
|
You can also add your own custom strategies to handle errors. All you need to do is to provide a callable object to `StoreModel.config.merge_errors` or as value of `:merge_errors`. It should accept three arguments - _attribute_, _base_errors_ and _store_model_errors_:
|
144
146
|
|
145
147
|
```ruby
|
@@ -4,7 +4,13 @@ module StoreModel
|
|
4
4
|
module CombineErrorsStrategies
|
5
5
|
class MergeErrorStrategy
|
6
6
|
def call(_attribute, base_errors, store_model_errors)
|
7
|
-
|
7
|
+
if Rails::VERSION::MAJOR < 6 || Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR.zero?
|
8
|
+
base_errors.copy!(store_model_errors)
|
9
|
+
else
|
10
|
+
store_model_errors.errors.each do |error|
|
11
|
+
base_errors.add(:configuration, :invalid, message: error.full_message)
|
12
|
+
end
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
data/lib/store_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: store_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|