rename_keys 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a0dcc4059b50a3d13e2463253b9939079059107
4
- data.tar.gz: 44c0c9825b795eaa266ba60366a1c92a71144245
3
+ metadata.gz: 9117311c21ce4c776a0fdec2df857485bdd684e4
4
+ data.tar.gz: 10f51c550b80cce77bb839c817a25c1bae9b6fb1
5
5
  SHA512:
6
- metadata.gz: f6507221bec72678f87ff22b2261bb2fe11a00a7ed1add209cf92f05c25cea14efd1346975ac630b7a69d8395e75fddd0261aab01178782879aa821275a8a15e
7
- data.tar.gz: 7dae8e2a726ae4c0558635b9819d4d9297faa43d42c4ab2d35018311edc666f5cc01ce41a9b1761c96186c45edd2a398add3fcc587a5fb78293cd16bb6068839
6
+ metadata.gz: 7110da626223d7f8dc36ba6a229b920d0e9a2e0dc1e810436048d1efe3a6076266132a5d64e4d3ee3eb42d7f95c2e739e9980d4a00e9f1e7bb2b1118cd1b2a4f
7
+ data.tar.gz: 3bd2f909738b38cb39b2dd956035b4c9d7de3c0f6be8ee95e0002909355cb62cc195f10aed7147253f1bb9e7e676e928d1dc033460555ad7dcafa518c3045e1c
@@ -8,21 +8,22 @@ module CoreExtensions
8
8
  module Keys
9
9
  def rename_keys(mapping)
10
10
  result = {}
11
- self.map do |k, v|
11
+
12
+ self.each do |k, v|
12
13
  mapped_key = mapping[k] ? mapping[k] : k
13
14
 
14
15
  # If this entry is a deep/nested hash, recursively change key names.
15
- result[mapped_key] = v.class.to_s == "Hash" ? v.rename_keys(mapping) : v
16
+ result[mapped_key] = v.kind_of?(::Hash) ? v.rename_keys(mapping) : v
16
17
 
17
- result[mapped_key] = v.collect{ |obj| obj.rename_keys(mapping) if obj.class.to_s == "Hash" } if v.class.to_s == "Array"
18
+ result[mapped_key] = v.collect{ |obj| obj.rename_keys(mapping) if obj.kind_of?(::Hash) } if v.kind_of?(::Array)
18
19
  end
19
20
 
20
21
  # If used within a Rails project, allow reference by either symbol or string.
21
22
  result.respond_to?(:with_indifferent_access) ? result.with_indifferent_access : result
22
- end
23
+ end
23
24
  end
24
25
  end
25
26
  end
26
27
 
27
28
  # Actually monkey-patch the Ruby core Hash class
28
- Hash.include CoreExtensions::Hash::Keys
29
+ Hash.include ::CoreExtensions::Hash::Keys
@@ -1,3 +1,3 @@
1
1
  module RenameKeys
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rename_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel LeGrand
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler