gorilla-patch 2.7.0 → 2.8.0

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/blank.rb +19 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 887de8990e1224553fa35db2f6e495b1bf9596596f9c2cc8fa5d3de715568bbb
4
- data.tar.gz: 01a6c2150330bb094d7fb1ef08741641da109c209022d53144e9e138f62441cb
3
+ metadata.gz: 22374520b1e3516e6bb6dddbf78792678cbe479a5acfbb3dd98700c9878df750
4
+ data.tar.gz: 4768691dcfa6026be3b471b0d6dec23f12c2c8199821183ac859475c2a722c8e
5
5
  SHA512:
6
- metadata.gz: 6f3cec4c5439c1d9994032745dcb3cd953921fa241224f430ac51f91911c2a26168a8ee87e3166e2d5dbd2eccac17a74a2981b940a5cb962f3dce07c2e7d2e2f
7
- data.tar.gz: 396007ebfd7f98bbccc3d8015d865665db0d188e247f9bae524b18ce4e3594a7f278e1fbde8e41002683645a31435ef4c1bc90de637c2ae7fab1dce8be273c63
6
+ metadata.gz: 6d0b6a5faed7793a3a76b1952ad36ed44f91a9f786e4479d9ecbfc7a87ad541915c8f0e08144d21e3cac668a6b9d9952a15dfa9220127152bd7b757274566601
7
+ data.tar.gz: 9bd88749f81ba168283772b3267424ab791ce1b93d167caf76fe79742205ad584d1a5c893deb3b289b9ec502cf4858ca26cf18decf74ad3cca4ebaf56c2a3f9b
@@ -17,12 +17,30 @@ module GorillaPatch
17
17
  end
18
18
  end
19
19
 
20
+ # rubocop:disable Metrics/BlockLength
20
21
  [Array, Hash].each do |klass|
21
22
  refine klass do
22
23
  def reject_blank_strings!
23
24
  replace reject_blank_strings
24
25
  end
25
26
 
27
+ def nilify_blank_strings
28
+ result = map do |element|
29
+ if element.is_a?(String) && element.blank?
30
+ nil
31
+ elsif element.is_a?(Enumerable)
32
+ element.nilify_blank_strings
33
+ else
34
+ element
35
+ end
36
+ end
37
+ is_a?(Hash) ? result.to_h : result
38
+ end
39
+
40
+ def nilify_blank_strings!
41
+ replace nilify_blank_strings
42
+ end
43
+
26
44
  private
27
45
 
28
46
  def deep_value_empty?(value)
@@ -43,6 +61,7 @@ module GorillaPatch
43
61
  end
44
62
  end
45
63
  end
64
+ # rubocop:enable Metrics/BlockLength
46
65
 
47
66
  refine Array do
48
67
  using GorillaPatch::DeepDup
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: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov