paramore 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paramore/cast_parameters.rb +6 -2
- data/lib/paramore/field.rb +7 -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: 8e8663a895e1498608035c7717e8a881617d1ba889e67e6115472117717963fc
|
4
|
+
data.tar.gz: 3e6b5675baeae13d31abee6f1ed4b77261ed233be87e42a5277ce803f5801c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b51afaf562c8671afadd367cdb9388d50b77939d5aaf939cc54f3b00e0046ee8ff218a54c04e29db3979edfb46635a2fb387643dc726c61c513a658c821c9a2a
|
7
|
+
data.tar.gz: 24528d33bbb924bfb1c75f7ee24a9c0853ae0c6af357695df0a3e29771a2e6084df26a4259e494d548bac1e26c781b862a5d0b4e1df9a480cdeb515d3e1ceaeb
|
@@ -18,7 +18,7 @@ module Paramore
|
|
18
18
|
|
19
19
|
case field.type
|
20
20
|
when Hash
|
21
|
-
typecast_hash(field
|
21
|
+
typecast_hash(field, value || {})
|
22
22
|
when Array
|
23
23
|
typecast_array(field, value)
|
24
24
|
else
|
@@ -31,7 +31,11 @@ module Paramore
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def typecast_hash(field, hash)
|
34
|
-
|
34
|
+
result = field
|
35
|
+
.type
|
36
|
+
.reject { |name, inner_field| !hash.key?(name) && !inner_field.required? }
|
37
|
+
.to_h { |name, inner_field| [name, cast(inner_field, hash[name], name)] }
|
38
|
+
field.compact? ? result.compact : result
|
35
39
|
end
|
36
40
|
|
37
41
|
def typecast_array(field, array)
|
data/lib/paramore/field.rb
CHANGED
@@ -5,14 +5,20 @@ module Paramore
|
|
5
5
|
compact: false,
|
6
6
|
default: nil,
|
7
7
|
empty: true,
|
8
|
+
required: true,
|
8
9
|
}.freeze
|
9
10
|
|
10
|
-
def initialize(given_type, null:, compact:, default:, empty:)
|
11
|
+
def initialize(given_type, null:, compact:, default:, empty:, required:)
|
11
12
|
@given_type = given_type
|
12
13
|
@nullable = null
|
13
14
|
@compact = compact
|
14
15
|
@allow_empty = empty
|
15
16
|
@default = default
|
17
|
+
@required = required
|
18
|
+
end
|
19
|
+
|
20
|
+
def required?
|
21
|
+
@required
|
16
22
|
end
|
17
23
|
|
18
24
|
def allow_empty?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paramore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Kairevičius
|
@@ -101,7 +101,7 @@ licenses:
|
|
101
101
|
- MIT
|
102
102
|
metadata: {}
|
103
103
|
post_install_message: |
|
104
|
-
Thank you for installing Paramore 3.
|
104
|
+
Thank you for installing Paramore 3.4.0 !
|
105
105
|
From the command line you can run `paramore` to generate a configuration file
|
106
106
|
|
107
107
|
More details here : https://github.com/lumzdas/paramore/blob/master/README.md
|