gorilla-patch 0.0.15 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gorilla-patch/hash.rb +14 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4582143df2420c933fbfc74e1387cc810642f9e2
4
- data.tar.gz: 45ab6b9aaf6d271cbfde30d7f9e593b9335a5ae2
3
+ metadata.gz: 4b0b12c39a1af4f5ee11e9145330af57bd412991
4
+ data.tar.gz: 81cb1b2f8052a5d0f7ac82086b88681ac4541c0e
5
5
  SHA512:
6
- metadata.gz: faca69c1cbd83280f9cd5c76d4c80f7603f01a841392716ef98b1e816f5afa5db5cec5e36405b12ca18f989c7883abb14b52d05c76771d83f6f1a4fc9099838b
7
- data.tar.gz: 70a40905af465b37a9f9d2fff2bc1ec4e8fa714ec0d2a3f142ef5b79f0fa71cf295e5d44695508f041e106cb0c7a94472b62a303eca6b4d3ea6fa1bba76a2c66
6
+ metadata.gz: 5a817b237f13748ba31de42c665a6de3bfb08d45d4f9971f7162de168069d96a9af1f0985a785ac2cee0af746913be866422ec90952f98f19a6c73fa134efd37
7
+ data.tar.gz: 9f3e1706f771036b70d9fb7f07af42479a41b85931654a423b58e3204e9f34688ef993863e1486071d5ea41c0612e4aca035317f534f72bb1907214b26094019
@@ -4,7 +4,7 @@ module GorillaPatch
4
4
  refine Hash do
5
5
  def keys_to_sym(deep: false)
6
6
  each_with_object({}) do |(key, val), hash_sym|
7
- val = val.keys_to_sym(deep: deep) if deep && val.is_a?(Hash)
7
+ val = deep_symbolize_keys_in(val) if deep
8
8
  key = key.to_sym if key.respond_to?(:to_sym)
9
9
  hash_sym[key] = val
10
10
  end
@@ -66,6 +66,19 @@ module GorillaPatch
66
66
  def keys?(*keys)
67
67
  keys.all? { |k| key?(k) }
68
68
  end
69
+
70
+ private
71
+
72
+ def deep_symbolize_keys_in(object)
73
+ case object
74
+ when Hash
75
+ object.keys_to_sym(deep: true)
76
+ when Array
77
+ object.map { |el| deep_symbolize_keys_in(el) }
78
+ else
79
+ object
80
+ end
81
+ end
69
82
  end
70
83
  end
71
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorilla-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Refine Ruby Core classes.
14
14
  email: alex.wayfer@gmail.com