nested-hstore 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f23d654b452c5c198b9808b800e999db668126e2
4
- data.tar.gz: c0b4b22a115b40f2228a1899be2979115373728e
3
+ metadata.gz: 5a073ad53c3250a08a6a1382d45d2ccb9653f928
4
+ data.tar.gz: ce1ddadc1b3ce28bb1559798b4e4710f193f6c4d
5
5
  SHA512:
6
- metadata.gz: aff5204a542e2d9f79363064d15571b21b8976e27e994395fe6c050a5219260f52b86e0213ffa9d5591c1626ab51be5404ce0625dbfacb0e244ad75b9f615fc2
7
- data.tar.gz: 1346d82a5f421f48e795643d9470402d5af1d9e55b404ad615c85fab9ecdc36834777675907c25d43f98c86288b06094e368bf46417b1b999387f059c9a1faf9
6
+ metadata.gz: 8ee8a7281ea28746bc8ab0a49e51527f79b145f93982d0d1db269ee3ed96c12ef482a5571d19b8e2a5de348b634e6909116ff716b3bba8f4f98fde71d0cab24a
7
+ data.tar.gz: 45386c62a1a2bc42d3f07c05e1aab1c1cd9ca8157ea2249ed20673ccb9861b7c82625205947bd2e733ee194dabcd3dfdefdddd9d62c837cc1673d316e9430215
data/README.md CHANGED
@@ -42,6 +42,9 @@ user.my_property = [
42
42
  }
43
43
  ]
44
44
 
45
+ # Boolean
46
+ user.my_property = true
47
+
45
48
  # Integer
46
49
  user.my_property = 43
47
50
 
@@ -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
- if value.is_a?(Array)
19
+ case value
20
+ when Array
19
21
  type = :array
20
22
  hash = array_to_hash(value)
21
- elsif value.is_a?(Float)
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
- elsif value.is_a?(Hash)
29
+ when Hash
25
30
  type = :hash
26
31
  hash = standardize_value(value)
27
- elsif value.is_a?(Integer)
32
+ when Integer
28
33
  type = :integer
29
34
  hash = { @value_key => value }
30
- elsif value.is_a?(String)
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
@@ -1,3 +1,3 @@
1
1
  module NestedHstore
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
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.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-01-10 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord