nested-hstore 0.1.1 → 0.1.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/README.md +3 -0
- data/lib/nested_hstore/serializer.rb +12 -5
- data/lib/nested_hstore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a073ad53c3250a08a6a1382d45d2ccb9653f928
|
4
|
+
data.tar.gz: ce1ddadc1b3ce28bb1559798b4e4710f193f6c4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ee8a7281ea28746bc8ab0a49e51527f79b145f93982d0d1db269ee3ed96c12ef482a5571d19b8e2a5de348b634e6909116ff716b3bba8f4f98fde71d0cab24a
|
7
|
+
data.tar.gz: 45386c62a1a2bc42d3f07c05e1aab1c1cd9ca8157ea2249ed20673ccb9861b7c82625205947bd2e733ee194dabcd3dfdefdddd9d62c837cc1673d316e9430215
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@ module NestedHstore
|
|
5
5
|
@type_key = '__TYPE__'
|
6
6
|
@types_map = {
|
7
7
|
array: '__ARRAY__',
|
8
|
+
boolean: '__BOOLEAN__',
|
8
9
|
float: '__FLOAT__',
|
9
10
|
integer: '__INTEGER__',
|
10
11
|
string: '__STRING__'
|
@@ -15,19 +16,23 @@ module NestedHstore
|
|
15
16
|
|
16
17
|
def serialize(value)
|
17
18
|
return nil if value.nil?
|
18
|
-
|
19
|
+
case value
|
20
|
+
when Array
|
19
21
|
type = :array
|
20
22
|
hash = array_to_hash(value)
|
21
|
-
|
23
|
+
when FalseClass, TrueClass
|
24
|
+
type = :boolean
|
25
|
+
hash = { @value_key => value }
|
26
|
+
when Float
|
22
27
|
type = :float
|
23
28
|
hash = { @value_key => value }
|
24
|
-
|
29
|
+
when Hash
|
25
30
|
type = :hash
|
26
31
|
hash = standardize_value(value)
|
27
|
-
|
32
|
+
when Integer
|
28
33
|
type = :integer
|
29
34
|
hash = { @value_key => value }
|
30
|
-
|
35
|
+
when String
|
31
36
|
type = :string
|
32
37
|
hash = { @value_key => value }
|
33
38
|
else
|
@@ -44,6 +49,8 @@ module NestedHstore
|
|
44
49
|
deserialized = case type
|
45
50
|
when :array
|
46
51
|
hash.values.map { |v| decode_json_if_json(v) }
|
52
|
+
when :boolean
|
53
|
+
hash[@value_key] == 'true'
|
47
54
|
when :float
|
48
55
|
hash[@value_key].to_f
|
49
56
|
when :integer
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested-hstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Benner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|