hstore_accessor 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/lib/hstore_accessor.rb +1 -1
- data/lib/hstore_accessor/version.rb +1 -1
- data/spec/hstore_accessor_spec.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a5d9f17253e89a2b07c07a55c190d7c2a04b8ae
|
4
|
+
data.tar.gz: d285866bb3f67915215e7266d3de5d3f5a65a35d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf306876687e4430a522deb04adf10ccf166c4a3d6362e0daf0bdc119cd07345c265646e1f33131bd690f5b34292f1cb6908f51e94a7b15bf5cbcd1153fc5663
|
7
|
+
data.tar.gz: 7717387fe1db69737e6fc73c5cdb2d6967876ac027f5bc840b970ea846e1737b40d1e943b5d1e6aaea965e8652d000fb99ddd8fdaa32c80c8b0f905444e8acf3
|
data/lib/hstore_accessor.rb
CHANGED
@@ -22,7 +22,7 @@ module HstoreAccessor
|
|
22
22
|
|
23
23
|
DESERIALIZERS = {
|
24
24
|
:array => -> value { (value && value.split(SEPARATOR)) || [] },
|
25
|
-
:hash => -> value { JSON.parse(value) },
|
25
|
+
:hash => -> value { (value && JSON.parse(value)) || {} },
|
26
26
|
:integer => -> value { value.to_i },
|
27
27
|
:float => -> value { value.to_f },
|
28
28
|
:time => -> value { Time.at(value.to_i) },
|
@@ -180,6 +180,7 @@ describe HstoreAccessor do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "returns an empty array if an array value is not set" do
|
183
|
+
expect(Product.new.tags).to eq []
|
183
184
|
product.tags = nil
|
184
185
|
product.save
|
185
186
|
product.reload
|
@@ -194,6 +195,7 @@ describe HstoreAccessor do
|
|
194
195
|
end
|
195
196
|
|
196
197
|
it "returns an empty hash if a hash value is not set" do
|
198
|
+
expect(Product.new.reviews).to eq({})
|
197
199
|
product.reviews = nil
|
198
200
|
product.save
|
199
201
|
product.reload
|