hash_mapper 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hash_mapper.rb +7 -5
- data/lib/hash_mapper/version.rb +1 -1
- 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: 3bddd2af1ce1793dad8c629df875b3896616603d26ca85d1373acf19bc366c8a
|
4
|
+
data.tar.gz: c3c7d3ea740effd2faa8e870025e1bdff510e99fd6d03981be91facb23f014b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae9aa35b6b73b898c1db69c1fe154578035286f1ed4bc77d8d413aa44b8225b8425c0b40f897236a07e9ba2b96520bc7c09b80d63d286cd4e2a0f8f1ecc05822
|
7
|
+
data.tar.gz: 5c708bb349d7aa178a5461e3e6076cb838ee3aef005eebc7437f85b135dc79c268f7dc08436211959f637ceb94a34ce0e291cc3eb7990a76757f15b2b665e797
|
data/lib/hash_mapper.rb
CHANGED
@@ -40,6 +40,8 @@ end
|
|
40
40
|
|
41
41
|
module HashMapper
|
42
42
|
DEFAULT_OPTIONS = {}.freeze
|
43
|
+
NO_VALUE = :hash_mapper_no_value
|
44
|
+
NO_DEFAULT = :hash_mapper_no_default
|
43
45
|
|
44
46
|
def self.extended(base)
|
45
47
|
base.class_eval do
|
@@ -130,7 +132,7 @@ module HashMapper
|
|
130
132
|
@path_from = path_from
|
131
133
|
@path_to = path_to
|
132
134
|
@delegated_mapper = options.fetch(:using, nil)
|
133
|
-
@default_value = options.fetch(:default,
|
135
|
+
@default_value = options.fetch(:default, NO_DEFAULT)
|
134
136
|
end
|
135
137
|
|
136
138
|
def process_into(output, input, method_name: :normalize, context: nil)
|
@@ -147,15 +149,15 @@ module HashMapper
|
|
147
149
|
else
|
148
150
|
v = h[e]
|
149
151
|
end
|
150
|
-
return
|
152
|
+
return NO_VALUE if v.nil?
|
151
153
|
v
|
152
154
|
end
|
153
155
|
delegated_mapper ? delegate_to_nested_mapper(value, method_name, context: context) : value
|
154
156
|
end
|
155
157
|
|
156
158
|
def set_value_in_output(output, path, value)
|
157
|
-
if value ==
|
158
|
-
if default_value ==
|
159
|
+
if value == NO_VALUE
|
160
|
+
if default_value == NO_DEFAULT
|
159
161
|
return
|
160
162
|
else
|
161
163
|
value = default_value
|
@@ -169,7 +171,7 @@ module HashMapper
|
|
169
171
|
when Array
|
170
172
|
value.map {|v| delegated_mapper.public_send(method_name, v, context: context)}
|
171
173
|
when nil
|
172
|
-
return
|
174
|
+
return NO_VALUE
|
173
175
|
else
|
174
176
|
delegated_mapper.public_send(method_name, value, context: context)
|
175
177
|
end
|
data/lib/hash_mapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|