apia 3.9.0 → 3.10.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: 9fb59d89e7e26c05b0b0e279eb0f719124fa157afd921832fd0387dd75e7c255
4
- data.tar.gz: bb27bfb8696bd004e3788a19e9c7fb7cf06d252a86128329c7d0291f14fccb56
3
+ metadata.gz: 3aacd55e16d85ac583d7b03ecf16a404174b41cc39c9ddd836157845b7ff5b44
4
+ data.tar.gz: de3681316508f67bc6a605b99a2cc2d3024daa94de7f99859aba55b326dfb78b
5
5
  SHA512:
6
- metadata.gz: fd4b815b0ec48f91cede4632dd3d28d2a288bdef73909efd31fb15b5399bcc610a39574aea3f5a24a025c8114775e2f21d52c8b0c795ffe365a711ac73836c22
7
- data.tar.gz: 92a19998772f84b97d77a57a4f3da0beca83d156a6b236200b77ff634dcf48c8781a2399f3d4e9ce8e24f6b7ce783b3343eea05dbc8dccd4f867ecda13566c66
6
+ metadata.gz: a19a5124b419464ba1e7577df5fc7b8b68d149233e55a20bc5e8230bff989c5eeb8a861c2f39dcebea76e2e6d6dd9a05ba31006bfd92370b10ab9093676f4534
7
+ data.tar.gz: 5a921f878a7586db2ba33d525390297f23e6e5b97b9a66809c127d1c30f1c050ae2bbcc06e0b865292679db6145f01d820de497fa9f33bada643ac1e014e050c
data/lib/apia/cors.rb CHANGED
@@ -17,18 +17,18 @@ module Apia
17
17
  return {} if @origin.nil?
18
18
 
19
19
  headers = {}
20
- headers['Access-Control-Allow-Origin'] = @origin
20
+ headers['access-control-allow-origin'] = @origin
21
21
 
22
22
  if @methods.is_a?(String)
23
- headers['Access-Control-Allow-Methods'] = @methods
23
+ headers['access-control-allow-methods'] = @methods
24
24
  elsif @methods.is_a?(Array) && @methods.any?
25
- headers['Access-Control-Allow-Methods'] = @methods.map(&:upcase).join(', ')
25
+ headers['access-control-allow-methods'] = @methods.map(&:upcase).join(', ')
26
26
  end
27
27
 
28
28
  if @headers.is_a?(String)
29
- headers['Access-Control-Allow-Headers'] = @headers
29
+ headers['access-control-allow-headers'] = @headers
30
30
  elsif @headers.is_a?(Array) && @headers.any?
31
- headers['Access-Control-Allow-Headers'] = @headers.join(', ')
31
+ headers['access-control-allow-headers'] = @headers.join(', ')
32
32
  end
33
33
 
34
34
  headers
@@ -15,6 +15,7 @@ module Apia
15
15
  attr_accessor :backend
16
16
  attr_accessor :array
17
17
  attr_accessor :null
18
+ attr_accessor :skip_if_null
18
19
  attr_accessor :condition
19
20
  attr_writer :type
20
21
  attr_accessor :include
@@ -38,6 +39,13 @@ module Apia
38
39
  @null == true
39
40
  end
40
41
 
42
+ # Should this field be skipped if the value is null?
43
+ #
44
+ # @return [Boolean]
45
+ def skip_if_null?
46
+ @skip_if_null == true
47
+ end
48
+
41
49
  # Is the result from this field expected to be an array?
42
50
  #
43
51
  # @return [Boolean]
@@ -83,8 +91,12 @@ module Apia
83
91
  def value(object, request: nil, path: [])
84
92
  raw_value = raw_value_from_object(object)
85
93
 
86
- return nil if raw_value.nil? && null?
87
- raise Apia::NullFieldValueError.new(self, object) if raw_value.nil?
94
+ if raw_value.nil?
95
+ return :skip if skip_if_null?
96
+ return nil if null?
97
+
98
+ raise Apia::NullFieldValueError.new(self, object)
99
+ end
88
100
 
89
101
  if array? && raw_value.is_a?(Array)
90
102
  raw_value.map { |v| type.cast(v, request: request, path: path) }
@@ -22,6 +22,7 @@ module Apia
22
22
  end
23
23
 
24
24
  field.null = options[:null] if options.key?(:null)
25
+ field.skip_if_null = options[:skip_if_null] if options.key?(:skip_if_null)
25
26
  field.array = options[:array] if options.key?(:array)
26
27
  field.include = options[:include] if options.key?(:include)
27
28
  field.backend = options[:backend] if options.key?(:backend)
@@ -14,6 +14,10 @@ module Apia
14
14
  @definition.null = value
15
15
  end
16
16
 
17
+ def skip_if_null(value)
18
+ @definition.skip_if_null = value
19
+ end
20
+
17
21
  def array(value)
18
22
  @definition.array = value
19
23
  end
@@ -21,6 +21,9 @@ module Apia
21
21
  field :array, type: :boolean do
22
22
  backend(&:array?)
23
23
  end
24
+ field :skip_if_null, type: :boolean do
25
+ backend(&:skip_if_null?)
26
+ end
24
27
 
25
28
  field :spec, type: FieldSpecOptionsSchemaType do
26
29
  backend do |field|
data/lib/apia/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apia
4
4
 
5
- VERSION = '3.9.0'
5
+ VERSION = '3.10.0'
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-17 00:00:00.000000000 Z
11
+ date: 2026-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64