hash_to_model_mapper 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/Gemfile.lock +5 -5
- data/lib/hash_to_model_mapper.rb +10 -1
- data/lib/hash_to_model_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: f7fa923c2a9c1559f91f4b1b944bb35951cbd70282786f168ea40e7e4564e5fd
|
4
|
+
data.tar.gz: a3231aa12a326524bb4086630961d7dc86b1cd0163b72d92876fc7600e7af077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 843800af6dcb7f403408f60070775fc1d2ba33f2d362100e3ffb245d4e06de50005b3c448e8df92091f9fcb1a93179e57999f2bd1398665cca8b5011b03b602c
|
7
|
+
data.tar.gz: 728b790c2519b31b5c74be025683b1d12cd21ff2047e2180f12fef9d267bf4a2608ac89dd7a5e1191926d91de61f0a1ec1c2d5a56ff8bb7c82243f37093a5a20
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hash_to_model_mapper (0.1.
|
4
|
+
hash_to_model_mapper (0.1.1)
|
5
5
|
activesupport (~> 5.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -32,15 +32,15 @@ GEM
|
|
32
32
|
rspec-core (~> 3.8.0)
|
33
33
|
rspec-expectations (~> 3.8.0)
|
34
34
|
rspec-mocks (~> 3.8.0)
|
35
|
-
rspec-core (3.8.
|
35
|
+
rspec-core (3.8.2)
|
36
36
|
rspec-support (~> 3.8.0)
|
37
|
-
rspec-expectations (3.8.
|
37
|
+
rspec-expectations (3.8.4)
|
38
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
39
|
rspec-support (~> 3.8.0)
|
40
|
-
rspec-mocks (3.8.
|
40
|
+
rspec-mocks (3.8.1)
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
42
|
rspec-support (~> 3.8.0)
|
43
|
-
rspec-support (3.8.
|
43
|
+
rspec-support (3.8.2)
|
44
44
|
spoon (0.0.6)
|
45
45
|
ffi
|
46
46
|
thread_safe (0.3.6)
|
data/lib/hash_to_model_mapper.rb
CHANGED
@@ -61,7 +61,16 @@ module HashToModelMapper
|
|
61
61
|
|
62
62
|
if (transformer = mapper.transformers[attribute_name])
|
63
63
|
if transformer.is_a? Hash
|
64
|
-
|
64
|
+
old_value = value
|
65
|
+
value = transformer.with_indifferent_access[value]
|
66
|
+
|
67
|
+
if value.nil? && !transformer.keys.any? { |key| key == :nil }
|
68
|
+
raise("Key not present in tansformer: \
|
69
|
+
Wrong key: #{old_value}\
|
70
|
+
Valid keys: #{transformer.keys.inspect}\
|
71
|
+
Path: #{path}")
|
72
|
+
end
|
73
|
+
|
65
74
|
elsif transformer.respond_to? :call
|
66
75
|
value = transformer.call(value)
|
67
76
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_to_model_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AlexVko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|