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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gorilla-patch/hash.rb +16 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6212b7f870161d6536f1ff42d895990ffa55e5f0
4
- data.tar.gz: d3391651b153b05b66380513ca404bb4f3bed38b
3
+ metadata.gz: 5880c867c3a8766fc62df237934174c7376343c4
4
+ data.tar.gz: 3c8450ffe8ed2a3d18f8c236d882e814fa974000
5
5
  SHA512:
6
- metadata.gz: 2603e273c8f241b4f8100b4dda459fd2254cea9db5cb6f7f9b6c5b8025390206d8b85b02c788a058876450c444344f8e3108cc42bde1f8888e6b945ca32c6232
7
- data.tar.gz: 1a51ca04f8f35944ed352597c0186f8a2527d837ed8ef9273c4c674c8f3ea740be9ee9501dcc16fa852a08872ea6e11b5353d0973e27caca6420a1d4342dce88
6
+ metadata.gz: 710ed823b3321d0710942c6b3361335874da17cb3cd009514325c66ad3ed467121d24ac1792b0766f8ddbe89bfd92f53892279c1f19baad7c58641421c4e937c
7
+ data.tar.gz: a1cc7d3bfdff2a20db122742a70333de8720ae8488fa0984e7eb77669b62007940bf088a1bad443379002477f073e01f2da4bcce1152e775c011a3ed5c460fae
@@ -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({}) { |(key, val), hash_sym| hash_sym[key.to_sym] = val }
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({}) { |(key, val), hash_s| hash_s[key.to_s] = val }
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.10
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-02-26 00:00:00.000000000 Z
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