active_form_objects 1.0.1 → 1.0.2
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 +4 -4
- data/lib/dsl/polymorphs.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca5f16d13a98051602acf2df9d62f65d0928f3c2ca6106138ead07acc8662c6f
|
4
|
+
data.tar.gz: 8fcbdf3e85e608f0558baa4d6ecc3497b3025a187045cb8ef7ab4ce1b3f8f16d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da7a647ffd6216ac8b8cd804e520a36190083ff938ee70f3c2ecafd9ffab1d9ec961913d22a45b5dc6658358e970b14f8c99658b531b672c4ea9aec02543e937
|
7
|
+
data.tar.gz: fb251b0ae7067aa8c8c7636acf824a54fa48b51590c7c4793c1dff7eb97ab9d48e5e44347964a01634f72097dccff53c423782438f8d7c7b212da15b269ee98a
|
data/lib/dsl/polymorphs.rb
CHANGED
@@ -9,7 +9,8 @@ module Dsl
|
|
9
9
|
|
10
10
|
class PolymorphValidator < ActiveModel::EachValidator
|
11
11
|
def validate_each(record, attribute, data)
|
12
|
-
return unless record.try(attribute).try(:id).nil? &&
|
12
|
+
return unless record.try(attribute).try(:id).nil? &&
|
13
|
+
record.try("#{attribute}_id".to_sym).nil? &&
|
13
14
|
!options[:keys].include?(data['type'].try(:to_sym))
|
14
15
|
record.errors.add(attribute, 'type must be included in the list')
|
15
16
|
end
|
@@ -38,7 +39,7 @@ module Dsl
|
|
38
39
|
key: key,
|
39
40
|
types: possible_types
|
40
41
|
}
|
41
|
-
send(:attributes, key)
|
42
|
+
send(:attributes, key, "#{key}_id")
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|