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.
- checksums.yaml +4 -4
- data/lib/gorilla-patch/blank.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22374520b1e3516e6bb6dddbf78792678cbe479a5acfbb3dd98700c9878df750
|
4
|
+
data.tar.gz: 4768691dcfa6026be3b471b0d6dec23f12c2c8199821183ac859475c2a722c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d0b6a5faed7793a3a76b1952ad36ed44f91a9f786e4479d9ecbfc7a87ad541915c8f0e08144d21e3cac668a6b9d9952a15dfa9220127152bd7b757274566601
|
7
|
+
data.tar.gz: 9bd88749f81ba168283772b3267424ab791ce1b93d167caf76fe79742205ad584d1a5c893deb3b289b9ec502cf4858ca26cf18decf74ad3cca4ebaf56c2a3f9b
|
data/lib/gorilla-patch/blank.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|