store_model 0.3.0 → 0.3.1
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/README.md +2 -0
- data/lib/store_model/types/array_type.rb +1 -0
- data/lib/store_model/types/json_type.rb +1 -1
- data/lib/store_model/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea446173092e4c6df74a466d2033931a75fe1872b4c52c56ff28563e777dfa6c
|
4
|
+
data.tar.gz: 7eb5bb8bd19def8aa41e6f4f1c4fc720f9724903742e3902acb8163fa5cdb500
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62ba626e10a6479408b8a503aaae94ea9ecf590b824719e7a19c7f108b886f0c24e455bc22ac88a24ba133d1d403618e2ad2e98964832185dc6cb04afa1a7b61
|
7
|
+
data.tar.gz: 2c92ebc0c68bd1584b6dabfbebfe83de6f0acccc682f01ce814ad129129c017678b6962043c25b490dae249251172abb871d9f69ec5d8ed57e01f102c3c65666
|
data/README.md
CHANGED
@@ -82,6 +82,8 @@ end
|
|
82
82
|
|
83
83
|
After that, your attribute will return array of `Configuration` instances.
|
84
84
|
|
85
|
+
> Heads up! Attribute is not the same as association, in this case - it's just a hash. `assign_attributes` (and similar) is going to _override_ the whole hash, not merge it with a previous value
|
86
|
+
|
85
87
|
## Validations
|
86
88
|
|
87
89
|
`StoreModel` supports all the validations shipped with `ActiveModel`. Start with defining validation for the store model:
|
@@ -17,6 +17,7 @@ module StoreModel
|
|
17
17
|
case value
|
18
18
|
when String then decode_and_initialize(value)
|
19
19
|
when Array then ensure_model_class(value)
|
20
|
+
when nil then value
|
20
21
|
else
|
21
22
|
raise StoreModel::Types::CastError,
|
22
23
|
"failed casting #{value.inspect}, only String or Array instances are allowed"
|
@@ -17,7 +17,7 @@ module StoreModel
|
|
17
17
|
case value
|
18
18
|
when String then decode_and_initialize(value)
|
19
19
|
when Hash then @model_klass.new(value)
|
20
|
-
when @model_klass then value
|
20
|
+
when @model_klass, nil then value
|
21
21
|
else
|
22
22
|
raise StoreModel::Types::CastError,
|
23
23
|
"failed casting #{value.inspect}, only String, " \
|
data/lib/store_model/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|