hash_ext 0.2.2 → 0.2.3

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: 4eb2208c7445ed318154e7356194a5df58cf78a6
4
- data.tar.gz: 4a8535a3b5269911a344a7374a31e9bb14a98fa2
3
+ metadata.gz: eba87bb627d260913baffdb6da736ed155ccef99
4
+ data.tar.gz: f44ace55737bf6249643940f8fea149bc176c7be
5
5
  SHA512:
6
- metadata.gz: 32c0e85a844b0c7427b2f57885ed6a8edc8f30b1ab61c0b4193ccfbc9e00bd1beda417a28947043f1f712b6763e5be476f7fe9c12121d3e22e3045afee17d58c
7
- data.tar.gz: 0698afb6f8c2a669e51dd02735885a9ee1767c21e1556dc0f21b05bc40cd944742c29f607ccb6cc7ef631c42622b599ef6b7fd70a688c4fb2ec31f30a2c1e4c5
6
+ metadata.gz: 6071d9756d9ca39ba7bcd151b32e357fdc454c010de8938c6680ce17cbace13386095b1cc6a7a813270dd0cc14c318af617fa1fb7d18e5a7d0aa67ed90cb03c4
7
+ data.tar.gz: 773ca805d092b144470489a2cd931cc515b5efa79c2b83afe345658171009da156056ae174ad33abdfb3d4c769650dc3aeb3e1bf8996f6cb49447d34870b90d1
@@ -30,7 +30,7 @@ class Hash
30
30
  def update(hash, &block)
31
31
  hash.each do |key, value|
32
32
  new_val = block && key?(key) ? block.call(key, self[key], value) : value
33
- store normalize_key(key), normalize_value(new_val)
33
+ store key, new_val
34
34
  end
35
35
  self
36
36
  end
@@ -51,6 +51,12 @@ class Hash
51
51
  super normalize_key(key), *args, &block
52
52
  end
53
53
 
54
+ def to_h
55
+ each_with_object({}) do |(key, value), hash|
56
+ hash[key] = value_to_h value
57
+ end
58
+ end
59
+
54
60
  private
55
61
 
56
62
  def normalize_key(key)
@@ -67,5 +73,15 @@ class Hash
67
73
  end
68
74
  end
69
75
 
76
+ def value_to_h(value)
77
+ if value.kind_of? Hash
78
+ value.to_h
79
+ elsif value.kind_of? Array
80
+ value.map { |v| value_to_h v }
81
+ else
82
+ value
83
+ end
84
+ end
85
+
70
86
  end
71
87
  end
@@ -1,3 +1,3 @@
1
1
  module HashExt
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler