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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9e5f917e94f83183d5efebfbcfb54553d828aba1911dc3d786f347ed8886b6c
4
- data.tar.gz: 9fdb2f8d07f20f126b35bb959168a00fa07845eba53f5ec56a1b7cecdd2aac5a
3
+ metadata.gz: fd6a8847ea2064ce01979e2ba05637c81c3af689ce899d079d5247b4ea5f714a
4
+ data.tar.gz: 490f158a345033a430d7c79df095f0fa5adf502f05888f0b74785d0ee270be8e
5
5
  SHA512:
6
- metadata.gz: '098925c4b5251af42c29bda6abd2576347490b23ccc8b2cc03b826b468899884cc7ce44a2d08aa9c44e63d8be4e489fdd4f96ff3f973abe7165fe832a702d3ca'
7
- data.tar.gz: d9a9460547b6ced56afa16bf3ea64caa8071c29e243dfc30af91d532d1a7f57b40c896107eec5a44374fa53291d3b548fdf67123dde99d38e143d0ba6d2728c0
6
+ metadata.gz: 526d48f8a2e4dd7a607d5c70f4c5ad0ea28fbc48fa6828b4eccef0658cb43383e86e96c264dc6955db8beaf3da48fc5bcf484a8ed11d4c170c342678c8ce83d4
7
+ data.tar.gz: 30e8ebd8802a2cbf13ee22d218a2d31b37840e3d39c06141897bc8f7a60c3d568381c463e9cb29f0c49156c8444c7d869740d1f4b350826b944b6832d77ab29c
@@ -0,0 +1,10 @@
1
+ # Change log
2
+
3
+ ## master
4
+
5
+ ## 0.1.1
6
+ - add handler to camelize_keys
7
+
8
+ ## 0.1.0
9
+ - add camelize_keys
10
+ - add symbolize_keys
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api_utils (0.1.0)
4
+ api_utils (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -13,7 +13,8 @@ module ApiUtils
13
13
  # camelize all hash keys
14
14
  # @param [Hash] hash
15
15
  # @return [Hash]
16
- def camelize_keys(hash) # rubocop:disable Metrics/MethodLength
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
@@ -1,3 +1,3 @@
1
1
  module ApiUtils
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvaykin