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.
- checksums.yaml +4 -4
- data/lib/gorilla-patch/hash.rb +14 -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: 4b0b12c39a1af4f5ee11e9145330af57bd412991
|
4
|
+
data.tar.gz: 81cb1b2f8052a5d0f7ac82086b88681ac4541c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a817b237f13748ba31de42c665a6de3bfb08d45d4f9971f7162de168069d96a9af1f0985a785ac2cee0af746913be866422ec90952f98f19a6c73fa134efd37
|
7
|
+
data.tar.gz: 9f3e1706f771036b70d9fb7f07af42479a41b85931654a423b58e3204e9f34688ef993863e1486071d5ea41c0612e4aca035317f534f72bb1907214b26094019
|
data/lib/gorilla-patch/hash.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|