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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7d4674d14687a7f9eb3547135c22df22c1cada2dc55b7f2b0f011462d20bf1a
|
|
4
|
+
data.tar.gz: f580dcdf234e49b933b1636f2a2c14d2ca11caf4d5364a70ec574763978c834c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33a16b4c739c5c13ba2374882d0997bea4cda29b00eef1c1afe7c810fe0247fab1ca6568bb225ac8e32617742b0ff9df85920518db7a4c062a223cdc688cee6b
|
|
7
|
+
data.tar.gz: d707cbf17e3df65f57a523e7695b5ce2c7d009b3aa28599b071fb0ec1ba910281af9224493708214654a979ffe6362d661d6d5410bcec93ffadc08e37c9f6f96
|
|
@@ -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)
|
data/lib/apiwork/version.rb
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2026-04-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|