store_model 1.6.0 → 1.6.1

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: f95beec42af3ceb37df12a044bf2d54d5536fdc65f0c85326f09ff7539615a5d
4
- data.tar.gz: c2a5a33c8812559c03e4ab6825729396dd4ff6cfd45443f4cf599342d98d6255
3
+ metadata.gz: f4731608dcbfcf457b9e0cce52d04766ccbc7ea38fc061a6af61ef3b6edc2a3c
4
+ data.tar.gz: d5a84b08a03420aece94ea78a0c620d3e486ac4046173d6b6091974f94f4c507
5
5
  SHA512:
6
- metadata.gz: 7c25bf925defb2c6535fe3be1dd870e4e82c06e40ddc25b7ecea9032141f13c4413631f89d5d1a668777622956e7dcbd8f296146596f5686a5d512da6663db93
7
- data.tar.gz: 6131162e8eb82aec61b2ffcf8b8789bd59c9a036f3b07665d6df0c3cf20d9cbfa187dd5279ced4ff3dcfacc072d14bf9aa1f9c64ccb950f455111679f3dd01e0
6
+ metadata.gz: 9e78d0f1f95f9982ed599f5701e06d48936f2be349189764b5fa7df6fc7a0c9ee71a17d1ae50a74c1a70bcbb037feb8e33db43131de1e880efb74c9a2c0e9c9d
7
+ data.tar.gz: 7d5d82c70fe870f3abc767faae918a2a8f11bc6a9d645a8d36d12800da19951b9a8f018cdc336e5c35979a5e21847a034d1d9b76196a87c6bd1a1d0389062a80
@@ -22,20 +22,21 @@ module ActiveModel
22
22
 
23
23
  case record.type_for_attribute(attribute).type
24
24
  when :json, :polymorphic
25
- call_json_strategy(attribute, record.errors, value)
25
+ call_json_strategy(record, attribute, value)
26
26
  when :array, :polymorphic_array
27
- call_array_strategy(attribute, record.errors, value)
27
+ call_array_strategy(record, attribute, value)
28
28
  end
29
29
  end
30
30
 
31
31
  private
32
32
 
33
- def call_json_strategy(attribute, record_errors, value)
34
- strategy.call(attribute, record_errors, value.errors) if value.invalid?
33
+ def call_json_strategy(record, attribute, value)
34
+ strategy.call(attribute, record.errors, value.errors) if value.invalid?(record.validation_context)
35
35
  end
36
36
 
37
- def call_array_strategy(attribute, record_errors, value)
38
- array_strategy.call(attribute, record_errors, value) if value.select(&:invalid?).present?
37
+ def call_array_strategy(record, attribute, value)
38
+ any_invalid = value.select { |v| v.invalid?(record.validation_context) }.present?
39
+ array_strategy.call(attribute, record.errors, value) if any_invalid
39
40
  end
40
41
 
41
42
  def strategy
@@ -46,7 +46,6 @@ module StoreModel
46
46
 
47
47
  def define_map_readers(name, mapping)
48
48
  define_method("#{name}_values") { mapping }
49
- alias_method(ActiveSupport::Inflector.pluralize(name), "#{name}_values")
50
49
  singleton_class.define_method("#{name}_values") { mapping }
51
50
  singleton_class.alias_method(ActiveSupport::Inflector.pluralize(name), "#{name}_values")
52
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel # :nodoc:
4
- VERSION = "1.6.0"
4
+ VERSION = "1.6.1"
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: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-19 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord