hash_dot 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hash.rb +16 -2
  3. data/lib/hash_dot/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e41159a2e0f3156c53e8c66f6b769ba59c4740e3
4
- data.tar.gz: eb171a61ccfdbb299de59d2856eb0e8607226db2
3
+ metadata.gz: 025bbbf6717d54caf3ac01e47c898c073fd92807
4
+ data.tar.gz: 56fe882509329f3c75b7ac26cca082a608a151ad
5
5
  SHA512:
6
- metadata.gz: dc9222cf1cd7d977883d98b3b4613a571468d3820aaecec553771cd903fbdd59ab68b582f512d00229d29caa51a8583502696ee73112b94691e0ee419ae4ca88
7
- data.tar.gz: 530dbd4dcefa3610347bbaaee131d1e62d88802512477647af55e8116115e0ffb216a0708357f3cf4dcb99f87435f40a81ff4d1e238c566c0d673c4d7ebc06c3
6
+ metadata.gz: 1d132f533f12e56e2eae538007eff03c5c2839d16445040de3b2eda9d678903fc25958506b90f44556582a705676259b165330dcc34202b01702da3f165276ce
7
+ data.tar.gz: 7c9ca35e1a9cb15fb3b99b12f2b137cba4a42c1c20c5cbb79a8a950d5595f0bd52146dd9a09ca989a5e3b351cb3cbcffc8b0eb7076ce4b921c1551519929e098
data/lib/hash.rb CHANGED
@@ -33,14 +33,28 @@ class Hash
33
33
  return true if key?(prop)
34
34
  super(method, include_all)
35
35
  end
36
-
36
+
37
37
  private
38
38
 
39
+ def dotify_obj(obj, use_default: false)
40
+ case obj
41
+ when Array
42
+ obj.each do |el|
43
+ dotify_obj(el)
44
+ end
45
+ when Hash
46
+ dotify_hash(obj, use_default: use_default)
47
+ # else no-op
48
+ end
49
+ end
50
+
39
51
  def dotify_hash(hash, use_default: false)
40
52
  hash.use_dot_syntax = true
41
53
  hash.hash_dot_use_default = use_default
42
54
 
43
- hash.keys.each { |key| dotify_hash(hash[key], use_default: use_default) if hash[key].is_a?(Hash) }
55
+ hash.each_value do |val|
56
+ dotify_obj(val)
57
+ end
44
58
  end
45
59
 
46
60
  def to_dot?
@@ -1,3 +1,3 @@
1
1
  module HashDot
2
- VERSION = "2.2.0".freeze
2
+ VERSION = "2.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_dot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Steel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-20 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler