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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe31f43187a97021f54c79cbc8372b7e2b1c5a3c4bcb7b07b13def128bf69f34
|
|
4
|
+
data.tar.gz: '0456813d7c47e3a9888c23bd83dc90c233f8919734766e348c064350c3d502ce'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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,
|
|
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
|
|
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)
|
data/lib/store_model/model.rb
CHANGED
|
@@ -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
|
data/lib/store_model/version.rb
CHANGED