api_utils 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/lib/api_utils.rb +4 -3
- data/lib/api_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd6a8847ea2064ce01979e2ba05637c81c3af689ce899d079d5247b4ea5f714a
|
4
|
+
data.tar.gz: 490f158a345033a430d7c79df095f0fa5adf502f05888f0b74785d0ee270be8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 526d48f8a2e4dd7a607d5c70f4c5ad0ea28fbc48fa6828b4eccef0658cb43383e86e96c264dc6955db8beaf3da48fc5bcf484a8ed11d4c170c342678c8ce83d4
|
7
|
+
data.tar.gz: 30e8ebd8802a2cbf13ee22d218a2d31b37840e3d39c06141897bc8f7a60c3d568381c463e9cb29f0c49156c8444c7d869740d1f4b350826b944b6832d77ab29c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/api_utils.rb
CHANGED
@@ -13,7 +13,8 @@ module ApiUtils
|
|
13
13
|
# camelize all hash keys
|
14
14
|
# @param [Hash] hash
|
15
15
|
# @return [Hash]
|
16
|
-
|
16
|
+
# @param [Proc] handler Value will be result of handler
|
17
|
+
def camelize_keys(hash, handler = ->(val) { val })
|
17
18
|
hash.each.with_object({}) do |(key, val), obj|
|
18
19
|
obj[camelize(key.to_s)] =
|
19
20
|
case val
|
@@ -21,10 +22,10 @@ module ApiUtils
|
|
21
22
|
camelize_keys(val)
|
22
23
|
when Array
|
23
24
|
val.map do |item|
|
24
|
-
item.instance_of?(Hash) ? camelize_keys(item) : item
|
25
|
+
item.instance_of?(Hash) ? camelize_keys(item) : handler.call(item)
|
25
26
|
end
|
26
27
|
else
|
27
|
-
val
|
28
|
+
handler.call(val)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
data/lib/api_utils/version.rb
CHANGED