paramore 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58abb01856e9f20f59b4bf4608e8c5444973970ac6845b96b7c12c117a0596bc
4
- data.tar.gz: 5ed6febf9385fe094736e3e2f8b29dd8a0db845a1e3837474daf64f2a06c7bc7
3
+ metadata.gz: 8e8663a895e1498608035c7717e8a881617d1ba889e67e6115472117717963fc
4
+ data.tar.gz: 3e6b5675baeae13d31abee6f1ed4b77261ed233be87e42a5277ce803f5801c0e
5
5
  SHA512:
6
- metadata.gz: f21c1603f15ac94639370a7fdeaa8bbaac55c0b56e5693409ebf404272bf03df1bcbae1799888728d72b15aaf25e7c1384ab34190c38fe9c9de8de7fb2e36c85
7
- data.tar.gz: d064f814eeccc3692a8cf7ed5502096c47657ce30b4d12300f9d57b3cf31a58724b6e576098e30a9d40a13e44793c7544006e1ead13eaef0dcf83d6b1ed053d8
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.type, value || {})
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
- field.to_h { |name, field| [name, cast(field, hash[name], name)] }
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)
@@ -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.3.0
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.3.0 !
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