apiwork 0.6.0 → 0.6.1

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: e82aa84563a02e2459a6d464c65cd50e5bb3edcb762a0a5b9412e79475663c52
4
- data.tar.gz: ac7da6d7f57a6be553fa8809da6f449029ac9d9c42e4da24c780e9f4364c1a4a
3
+ metadata.gz: e7d4674d14687a7f9eb3547135c22df22c1cada2dc55b7f2b0f011462d20bf1a
4
+ data.tar.gz: f580dcdf234e49b933b1636f2a2c14d2ca11caf4d5364a70ec574763978c834c
5
5
  SHA512:
6
- metadata.gz: 4f7bd06c06cb8485762e066e8efb64d21af6258b85442bbbc9813b1359e3d38706314dd285fe48de42d8a5526590c08508c436abdb8acfe0c23c203ade8391db
7
- data.tar.gz: 7ce587bd8232382e56a8f5da4ba33d1dd942482e018e1e968aacb1f1a6be8bb778d85dec4ee425799a350b0afdd7a4c7277c264b661209bb16f6404e7ec9bf32
6
+ metadata.gz: 33a16b4c739c5c13ba2374882d0997bea4cda29b00eef1c1afe7c810fe0247fab1ca6568bb225ac8e32617742b0ff9df85920518db7a4c062a223cdc688cee6b
7
+ data.tar.gz: d707cbf17e3df65f57a523e7695b5ce2c7d009b3aa28599b071fb0ec1ba910281af9224493708214654a979ffe6362d661d6d5410bcec93ffadc08e37c9f6f96
@@ -59,6 +59,8 @@ module Apiwork
59
59
  end
60
60
 
61
61
  representation_class.attributes.each do |name, attribute|
62
+ next if attribute.write_only?
63
+
62
64
  param_options = {
63
65
  deprecated: attribute.deprecated?,
64
66
  description: attribute.description,
@@ -83,7 +83,8 @@ module Apiwork
83
83
  :of,
84
84
  :optional,
85
85
  :preload,
86
- :type
86
+ :type,
87
+ :write_only
87
88
 
88
89
  def initialize(
89
90
  name,
@@ -105,6 +106,7 @@ module Apiwork
105
106
  sortable: false,
106
107
  type: nil,
107
108
  writable: false,
109
+ write_only: false,
108
110
  &block
109
111
  )
110
112
  @name = name
@@ -157,6 +159,7 @@ module Apiwork
157
159
  @example = example
158
160
  @format = format
159
161
  @deprecated = deprecated
162
+ @write_only = write_only
160
163
 
161
164
  validate_min_max_range!
162
165
  validate_format!
@@ -225,6 +228,14 @@ module Apiwork
225
228
  [true, action].include?(@writable)
226
229
  end
227
230
 
231
+ # @api public
232
+ # Whether this attribute is write-only.
233
+ #
234
+ # @return [Boolean]
235
+ def write_only?
236
+ @write_only
237
+ end
238
+
228
239
  def encode(value)
229
240
  result = @empty && value.nil? ? '' : value
230
241
  @encode ? @encode.call(result) : result
@@ -222,6 +222,9 @@ module Apiwork
222
222
  # Use an explicit type or block in those cases.
223
223
  # @param writable [Boolean, Symbol] (false) [:create, :update]
224
224
  # The write access. `true` for both create and update, `:create` for create only, `:update` for update only.
225
+ # @param write_only [Boolean] (false)
226
+ # Whether the attribute is write-only. Write-only attributes are excluded from response
227
+ # serialization and response types but remain in writable payloads.
225
228
  # @yieldparam element [Representation::Element]
226
229
  # @return [void]
227
230
  #
@@ -286,6 +289,7 @@ module Apiwork
286
289
  sortable: false,
287
290
  type: nil,
288
291
  writable: false,
292
+ write_only: false,
289
293
  &block
290
294
  )
291
295
  self.attributes = attributes.merge(
@@ -309,6 +313,7 @@ module Apiwork
309
313
  sortable:,
310
314
  type:,
311
315
  writable:,
316
+ write_only:,
312
317
  &block
313
318
  ),
314
319
  )
@@ -21,6 +21,8 @@ module Apiwork
21
21
  add_discriminator_field(fields) if @representation_class.subclass?
22
22
 
23
23
  @representation_class.attributes.each do |name, attribute|
24
+ next if attribute.write_only?
25
+
24
26
  value = @representation.respond_to?(name) ? @representation.public_send(name) : @representation.record.public_send(name)
25
27
  value = map_type_column_output(name, value)
26
28
  value = attribute.encode(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apiwork
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - skiftle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-03 00:00:00.000000000 Z
11
+ date: 2026-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails