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: 9c3afb6c889480d5e06a1532206001a7080400b8617a9c87564bc1658656292c
4
- data.tar.gz: bf50f80defd77d3774b5aae9658e3421b914e01b55ee9e547c61fedb715672f4
3
+ metadata.gz: 917f6d81bda1120cd7801117957d7ccd65e16214816dcac19176852abd54a46a
4
+ data.tar.gz: 682125c5da079cc5f9b996020d301a89c2c066206c202d88e790c04cf43b22c4
5
5
  SHA512:
6
- metadata.gz: 0ae10274f4904b73e4763b8b313d9fb896b88ab060c1bc929168ce0f671fc316d40b1c1f0a10238130a91803d0ea397cbf93a35e59da242cc776d3935a438050
7
- data.tar.gz: 92b840f816dd7799691b67171d7ab2426ad345ad9bd0b7f51468071d876c955c42a17588483ceffa1f8230bd4b1272672ccd6b05dd2a139c26a40dd9b7230ed1
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
- base_errors.copy!(store_model_errors)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
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.2.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-04-30 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails