store_model 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c65c5b8e184e6b4f7c402a7a2a82df8228d2b55c7ad6352c3752ac988bc86943
4
- data.tar.gz: f2f404a6330ded65170e6256adb71c109592c6187a85d221d6887c965eeb9a1c
3
+ metadata.gz: fe31f43187a97021f54c79cbc8372b7e2b1c5a3c4bcb7b07b13def128bf69f34
4
+ data.tar.gz: '0456813d7c47e3a9888c23bd83dc90c233f8919734766e348c064350c3d502ce'
5
5
  SHA512:
6
- metadata.gz: cf0146c740b94e5591d16794431120afc4c28dfb3477757571d4d77fb8833836fccdb94d5776f9199f92164ab36029def584d3a802ee186b531916d82c098e6b
7
- data.tar.gz: ae1753153b834b2b02bfa2ec4afc767540833eea27f59e653c3dbf8435bba3c1810999fba5128d71ce97e38e31314bc5622c8a01eb3054e743acd337bfae1b09
6
+ metadata.gz: 54a697b1a4782fa6bf3a6f84972789f6b42aab7ef9702e243d7fa4b9d7a6c035ea1421a560eb848083dd414b9bd594d577ca82a50642718d80607d742db64561
7
+ data.tar.gz: d591bf765bb19d91cc7972762349075edbb5ec9d633f3b0e4b9c290069af132e35b9d011e4537de43c18f3de76ca863e8b0576d93502ac95b24e4abb250bedd3
data/README.md CHANGED
@@ -125,7 +125,7 @@ end
125
125
  ## Documentation
126
126
 
127
127
  1. [Installation](./docs/installation.md)
128
- 2. StoreModel::Model API:
128
+ 2. `StoreModel::Model` API:
129
129
  * [Instantiation](./docs/instantiation.md)
130
130
  * [Validations](./docs/validations.md)
131
131
  * [Enums](./docs/enums.md)
@@ -10,8 +10,8 @@ module StoreModel
10
10
  # @param base_errors [ActiveModel::Errors] errors object of the parent record
11
11
  # @param _store_model_errors [ActiveModel::Errors] errors object of the
12
12
  # StoreModel::Model attribute
13
- def call(attribute, base_errors, _store_model_errors)
14
- base_errors.add(attribute, :invalid)
13
+ def call(attribute, base_errors, store_model_errors)
14
+ base_errors.add(attribute, :invalid, errors: store_model_errors)
15
15
  end
16
16
  end
17
17
  end
@@ -7,9 +7,9 @@ module StoreModel
7
7
 
8
8
  def assign_parent_to_store_model_relation(attribute)
9
9
  assign_parent_to_singular_store_model(attribute)
10
- return unless attribute.is_a?(Array)
10
+ return if !attribute.is_a?(Array) && !attribute.is_a?(Hash)
11
11
 
12
- attribute.each(&method(:assign_parent_to_singular_store_model))
12
+ (attribute.try(:values) || attribute).each(&method(:assign_parent_to_singular_store_model))
13
13
  end
14
14
 
15
15
  def assign_parent_to_singular_store_model(item)
@@ -8,6 +8,7 @@ require "store_model/nested_attributes"
8
8
  module StoreModel
9
9
  # When included into class configures it to handle JSON column
10
10
  module Model # rubocop:disable Metrics/ModuleLength
11
+ # rubocop:disable Metrics/MethodLength
11
12
  def self.included(base) # :nodoc:
12
13
  base.include ActiveModel::Model
13
14
  base.include ActiveModel::Attributes
@@ -15,6 +16,10 @@ module StoreModel
15
16
  base.include ActiveModel::AttributeMethods
16
17
  base.include StoreModel::NestedAttributes
17
18
 
19
+ if ActiveModel::VERSION::MAJOR >= 8 && ActiveModel::VERSION::MINOR >= 1
20
+ base.include ActiveModel::Attributes::Normalization
21
+ end
22
+
18
23
  base.extend StoreModel::Enum
19
24
  base.extend StoreModel::TypeBuilders
20
25
 
@@ -22,6 +27,7 @@ module StoreModel
22
27
 
23
28
  base.extend(ClassMethods)
24
29
  end
30
+ # rubocop:enable Metrics/MethodLength
25
31
 
26
32
  # Class methods for StoreModel::Model
27
33
  module ClassMethods
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel # :nodoc:
4
- VERSION = "4.3.0"
4
+ VERSION = "4.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev