gorilla-patch 0.0.10 → 0.0.12
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 +16 -8
- 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: 5880c867c3a8766fc62df237934174c7376343c4
|
4
|
+
data.tar.gz: 3c8450ffe8ed2a3d18f8c236d882e814fa974000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710ed823b3321d0710942c6b3361335874da17cb3cd009514325c66ad3ed467121d24ac1792b0766f8ddbe89bfd92f53892279c1f19baad7c58641421c4e937c
|
7
|
+
data.tar.gz: a1cc7d3bfdff2a20db122742a70333de8720ae8488fa0984e7eb77669b62007940bf088a1bad443379002477f073e01f2da4bcce1152e775c011a3ed5c460fae
|
data/lib/gorilla-patch/hash.rb
CHANGED
@@ -2,21 +2,29 @@ module GorillaPatch
|
|
2
2
|
## Refine Hash class
|
3
3
|
module HashExt
|
4
4
|
refine Hash do
|
5
|
-
def keys_to_sym
|
6
|
-
each_with_object({})
|
5
|
+
def keys_to_sym(deep: false)
|
6
|
+
each_with_object({}) do |(key, val), hash_sym|
|
7
|
+
val = val.keys_to_sym(deep: deep) if deep && val.is_a?(Hash)
|
8
|
+
key = key.to_sym if key.respond_to?(:to_sym)
|
9
|
+
hash_sym[key] = val
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
|
-
def keys_to_sym!
|
10
|
-
hash_sym = keys_to_sym
|
13
|
+
def keys_to_sym!(deep: false)
|
14
|
+
hash_sym = keys_to_sym(deep: deep)
|
11
15
|
clear.merge! hash_sym
|
12
16
|
end
|
13
17
|
|
14
|
-
def keys_to_s
|
15
|
-
each_with_object({})
|
18
|
+
def keys_to_s(deep: false)
|
19
|
+
each_with_object({}) do |(key, val), hash_s|
|
20
|
+
val = val.keys_to_s(deep: deep) if deep && val.is_a?(Hash)
|
21
|
+
key = key.to_s if key.respond_to?(:to_s)
|
22
|
+
hash_s[key] = val
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
|
-
def keys_to_s!
|
19
|
-
hash_s = keys_to_s
|
26
|
+
def keys_to_s!(deep: false)
|
27
|
+
hash_s = keys_to_s(deep: deep)
|
20
28
|
clear.merge! hash_s
|
21
29
|
end
|
22
30
|
|
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.12
|
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-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Refine Ruby Core classes.
|
14
14
|
email: alex.wayfer@gmail.com
|