media_types-serialization 2.0.0 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +32 -32
- data/.github/workflows/publish-bookworm.yml +34 -33
- data/.github/workflows/publish-sid.yml +34 -33
- data/.gitignore +22 -22
- data/.idea/.rakeTasks +7 -7
- data/.idea/dictionaries/Derk_Jan.xml +6 -6
- data/.idea/encodings.xml +3 -3
- data/.idea/inspectionProfiles/Project_Default.xml +5 -5
- data/.idea/media_types-serialization.iml +76 -76
- data/.idea/misc.xml +6 -6
- data/.idea/modules.xml +7 -7
- data/.idea/runConfigurations/test.xml +19 -19
- data/.idea/vcs.xml +5 -5
- data/CHANGELOG.md +200 -190
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +4 -4
- data/Gemfile.lock +169 -0
- data/LICENSE.txt +21 -21
- data/README.md +1048 -1048
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/media_types/problem.rb +67 -67
- data/lib/media_types/serialization/base.rb +269 -269
- data/lib/media_types/serialization/error.rb +193 -193
- data/lib/media_types/serialization/fake_validator.rb +53 -53
- data/lib/media_types/serialization/serialization_dsl.rb +135 -135
- data/lib/media_types/serialization/serialization_registration.rb +245 -245
- data/lib/media_types/serialization/serializers/api_viewer.rb +383 -383
- data/lib/media_types/serialization/serializers/common_css.rb +212 -212
- data/lib/media_types/serialization/serializers/endpoint_description_serializer.rb +80 -80
- data/lib/media_types/serialization/serializers/fallback_not_acceptable_serializer.rb +85 -85
- data/lib/media_types/serialization/serializers/fallback_unsupported_media_type_serializer.rb +58 -58
- data/lib/media_types/serialization/serializers/input_validation_error_serializer.rb +93 -93
- data/lib/media_types/serialization/serializers/problem_serializer.rb +111 -111
- data/lib/media_types/serialization/utils/accept_header.rb +77 -77
- data/lib/media_types/serialization/utils/accept_language_header.rb +82 -82
- data/lib/media_types/serialization/version.rb +7 -7
- data/lib/media_types/serialization.rb +689 -682
- data/media_types-serialization.gemspec +48 -48
- metadata +10 -9
@@ -1,269 +1,269 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'media_types/serialization/error'
|
4
|
-
require 'media_types/serialization/fake_validator'
|
5
|
-
require 'media_types/serialization/serialization_registration'
|
6
|
-
require 'media_types/serialization/serialization_dsl'
|
7
|
-
|
8
|
-
module MediaTypes
|
9
|
-
module Serialization
|
10
|
-
class Base
|
11
|
-
module ClassMethods
|
12
|
-
def unvalidated(prefix)
|
13
|
-
self.serializer_validated = false
|
14
|
-
self.serializer_validator = FakeValidator.new(prefix)
|
15
|
-
self.serializer_input_registrations = {}
|
16
|
-
self.serializer_output_registrations = {}
|
17
|
-
end
|
18
|
-
|
19
|
-
def validator(validator = nil)
|
20
|
-
raise NoValidatorSetError if !defined? serializer_validator && validator.nil?
|
21
|
-
return serializer_validator if validator.nil?
|
22
|
-
|
23
|
-
self.serializer_validated = true
|
24
|
-
self.serializer_validator = validator
|
25
|
-
self.serializer_input_registrations = {}
|
26
|
-
self.serializer_output_registrations = {}
|
27
|
-
end
|
28
|
-
|
29
|
-
def disable_wildcards
|
30
|
-
self.serializer_disable_wildcards = true
|
31
|
-
end
|
32
|
-
|
33
|
-
def enable_wildcards
|
34
|
-
self.serializer_disable_wildcards = false
|
35
|
-
end
|
36
|
-
|
37
|
-
def output(view: nil, version: nil, versions: nil, &block)
|
38
|
-
versions = [version] if versions.nil?
|
39
|
-
raise VersionsNotAnArrayError unless versions.is_a? Array
|
40
|
-
|
41
|
-
raise ValidatorNotSpecifiedError, :output if serializer_validator.nil?
|
42
|
-
|
43
|
-
unless serializer_output_registrations.has_key? view
|
44
|
-
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
45
|
-
end
|
46
|
-
|
47
|
-
versions.each do |v|
|
48
|
-
validator = serializer_validator.view(view).version(v)
|
49
|
-
validator.override_suffix(:json) unless serializer_validated
|
50
|
-
|
51
|
-
serializer_output_registrations[view].register_block(
|
52
|
-
self,
|
53
|
-
validator,
|
54
|
-
v,
|
55
|
-
block,
|
56
|
-
false,
|
57
|
-
wildcards:
|
58
|
-
!serializer_disable_wildcards
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def output_raw(view: nil, version: nil, versions: nil, suffix: nil, &block)
|
64
|
-
versions = [version] if versions.nil?
|
65
|
-
raise VersionsNotAnArrayError unless versions.is_a? Array
|
66
|
-
|
67
|
-
raise ValidatorNotSpecifiedError, :output if serializer_validator.nil?
|
68
|
-
|
69
|
-
unless serializer_output_registrations.has_key? view
|
70
|
-
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
71
|
-
end
|
72
|
-
|
73
|
-
versions.each do |v|
|
74
|
-
validator = serializer_validator.view(view)
|
75
|
-
.version(v)
|
76
|
-
.override_suffix(suffix)
|
77
|
-
|
78
|
-
serializer_output_registrations[view].register_block(
|
79
|
-
self,
|
80
|
-
validator,
|
81
|
-
v,
|
82
|
-
block,
|
83
|
-
true,
|
84
|
-
wildcards: !serializer_disable_wildcards
|
85
|
-
)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def output_alias(
|
90
|
-
media_type_identifier,
|
91
|
-
view: nil,
|
92
|
-
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil,
|
93
|
-
hide_variant: false
|
94
|
-
)
|
95
|
-
validator = serializer_validator.view(view).override_suffix(suffix)
|
96
|
-
victim_identifier = validator.identifier
|
97
|
-
|
98
|
-
unless serializer_output_registrations.has_key? view
|
99
|
-
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
100
|
-
end
|
101
|
-
|
102
|
-
serializer_output_registrations[view].register_alias(
|
103
|
-
self,
|
104
|
-
media_type_identifier,
|
105
|
-
victim_identifier,
|
106
|
-
false,
|
107
|
-
hide_variant,
|
108
|
-
wildcards: !serializer_disable_wildcards
|
109
|
-
)
|
110
|
-
end
|
111
|
-
|
112
|
-
def output_alias_optional(
|
113
|
-
media_type_identifier,
|
114
|
-
view: nil,
|
115
|
-
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil,
|
116
|
-
hide_variant: false
|
117
|
-
)
|
118
|
-
validator = serializer_validator.view(view).override_suffix(suffix)
|
119
|
-
victim_identifier = validator.identifier
|
120
|
-
|
121
|
-
unless serializer_output_registrations.has_key? view
|
122
|
-
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
123
|
-
end
|
124
|
-
|
125
|
-
serializer_output_registrations[view].register_alias(
|
126
|
-
self,
|
127
|
-
media_type_identifier,
|
128
|
-
victim_identifier,
|
129
|
-
true,
|
130
|
-
hide_variant,
|
131
|
-
wildcards: !serializer_disable_wildcards
|
132
|
-
)
|
133
|
-
end
|
134
|
-
|
135
|
-
def input(view: nil, version: nil, versions: nil, &block)
|
136
|
-
versions = [version] if versions.nil?
|
137
|
-
raise VersionsNotAnArrayError unless versions.is_a? Array
|
138
|
-
|
139
|
-
raise ValidatorNotSpecifiedError, :input if serializer_validator.nil?
|
140
|
-
|
141
|
-
unless serializer_input_registrations.has_key? view
|
142
|
-
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
143
|
-
end
|
144
|
-
|
145
|
-
versions.each do |v|
|
146
|
-
validator = serializer_validator.view(view).version(v)
|
147
|
-
validator.override_suffix(:json) unless serializer_validated
|
148
|
-
|
149
|
-
serializer_input_registrations[view].register_block(self, validator, v, block, false)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def input_raw(view: nil, version: nil, versions: nil, suffix: nil, &block)
|
154
|
-
versions = [version] if versions.nil?
|
155
|
-
raise VersionsNotAnArrayError unless versions.is_a? Array
|
156
|
-
|
157
|
-
raise ValidatorNotSpecifiedError, :input if serializer_validator.nil?
|
158
|
-
|
159
|
-
unless serializer_input_registrations.has_key? view
|
160
|
-
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
161
|
-
end
|
162
|
-
|
163
|
-
versions.each do |v|
|
164
|
-
validator = serializer_validator.view(view).version(v).override_suffix(suffix)
|
165
|
-
|
166
|
-
serializer_input_registrations[view].register_block(self, validator, v, block, true)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def input_alias(
|
171
|
-
media_type_identifier,
|
172
|
-
view: nil,
|
173
|
-
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil
|
174
|
-
)
|
175
|
-
validator = serializer_validator.view(view).override_suffix(suffix)
|
176
|
-
victim_identifier = validator.identifier
|
177
|
-
|
178
|
-
unless serializer_input_registrations.has_key? view
|
179
|
-
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
180
|
-
end
|
181
|
-
|
182
|
-
serializer_input_registrations[view].register_alias(
|
183
|
-
self,
|
184
|
-
media_type_identifier,
|
185
|
-
victim_identifier,
|
186
|
-
false,
|
187
|
-
true,
|
188
|
-
wildcards: false
|
189
|
-
)
|
190
|
-
end
|
191
|
-
|
192
|
-
def input_alias_optional(
|
193
|
-
media_type_identifier,
|
194
|
-
view: nil,
|
195
|
-
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil
|
196
|
-
)
|
197
|
-
validator = serializer_validator.view(view).override_suffix(suffix)
|
198
|
-
victim_identifier = validator.identifier
|
199
|
-
|
200
|
-
unless serializer_input_registrations.has_key? view
|
201
|
-
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
202
|
-
end
|
203
|
-
|
204
|
-
serializer_input_registrations[view].register_alias(
|
205
|
-
self,
|
206
|
-
media_type_identifier,
|
207
|
-
victim_identifier,
|
208
|
-
true,
|
209
|
-
true,
|
210
|
-
wildcards: false
|
211
|
-
)
|
212
|
-
end
|
213
|
-
|
214
|
-
def serialize(victim, media_type_identifier, context:, dsl: nil, raw: nil)
|
215
|
-
dsl ||= SerializationDSL.new(self, context: context)
|
216
|
-
|
217
|
-
merged_output_registrations = SerializationRegistration.new(:output)
|
218
|
-
serializer_output_registrations.keys.each do |k|
|
219
|
-
merged_output_registrations = merged_output_registrations.merge(serializer_output_registrations[k])
|
220
|
-
end
|
221
|
-
|
222
|
-
merged_output_registrations.call(victim, media_type_identifier.to_s, context, dsl: dsl, raw: raw)
|
223
|
-
end
|
224
|
-
|
225
|
-
def deserialize(victim, media_type_identifier, context:)
|
226
|
-
merged_input_registrations = SerializationRegistration.new(:input)
|
227
|
-
serializer_input_registrations.keys.each do |k|
|
228
|
-
merged_input_registrations = merged_input_registrations.merge(serializer_input_registrations[k])
|
229
|
-
end
|
230
|
-
|
231
|
-
merged_input_registrations.call(victim, media_type_identifier, context)
|
232
|
-
end
|
233
|
-
|
234
|
-
def outputs_for(views:)
|
235
|
-
merged_output_registrations = SerializationRegistration.new(:output)
|
236
|
-
views.each do |k|
|
237
|
-
merged_output_registrations = merged_output_registrations.merge(serializer_output_registrations[k]) if serializer_output_registrations.has_key?(k)
|
238
|
-
end
|
239
|
-
|
240
|
-
merged_output_registrations
|
241
|
-
end
|
242
|
-
|
243
|
-
def inputs_for(views:)
|
244
|
-
merged_input_registrations = SerializationRegistration.new(:input)
|
245
|
-
views.each do |k|
|
246
|
-
merged_input_registrations = merged_input_registrations.merge(serializer_input_registrations[k]) if serializer_input_registrations.has_key?(k)
|
247
|
-
end
|
248
|
-
|
249
|
-
merged_input_registrations
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
def self.inherited(subclass)
|
254
|
-
super
|
255
|
-
|
256
|
-
subclass.extend(ClassMethods)
|
257
|
-
subclass.instance_eval do
|
258
|
-
class << self
|
259
|
-
attr_accessor :serializer_validated
|
260
|
-
attr_accessor :serializer_validator
|
261
|
-
attr_accessor :serializer_input_registrations
|
262
|
-
attr_accessor :serializer_output_registrations
|
263
|
-
attr_accessor :serializer_disable_wildcards
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'media_types/serialization/error'
|
4
|
+
require 'media_types/serialization/fake_validator'
|
5
|
+
require 'media_types/serialization/serialization_registration'
|
6
|
+
require 'media_types/serialization/serialization_dsl'
|
7
|
+
|
8
|
+
module MediaTypes
|
9
|
+
module Serialization
|
10
|
+
class Base
|
11
|
+
module ClassMethods
|
12
|
+
def unvalidated(prefix)
|
13
|
+
self.serializer_validated = false
|
14
|
+
self.serializer_validator = FakeValidator.new(prefix)
|
15
|
+
self.serializer_input_registrations = {}
|
16
|
+
self.serializer_output_registrations = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def validator(validator = nil)
|
20
|
+
raise NoValidatorSetError if !defined? serializer_validator && validator.nil?
|
21
|
+
return serializer_validator if validator.nil?
|
22
|
+
|
23
|
+
self.serializer_validated = true
|
24
|
+
self.serializer_validator = validator
|
25
|
+
self.serializer_input_registrations = {}
|
26
|
+
self.serializer_output_registrations = {}
|
27
|
+
end
|
28
|
+
|
29
|
+
def disable_wildcards
|
30
|
+
self.serializer_disable_wildcards = true
|
31
|
+
end
|
32
|
+
|
33
|
+
def enable_wildcards
|
34
|
+
self.serializer_disable_wildcards = false
|
35
|
+
end
|
36
|
+
|
37
|
+
def output(view: nil, version: nil, versions: nil, &block)
|
38
|
+
versions = [version] if versions.nil?
|
39
|
+
raise VersionsNotAnArrayError unless versions.is_a? Array
|
40
|
+
|
41
|
+
raise ValidatorNotSpecifiedError, :output if serializer_validator.nil?
|
42
|
+
|
43
|
+
unless serializer_output_registrations.has_key? view
|
44
|
+
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
45
|
+
end
|
46
|
+
|
47
|
+
versions.each do |v|
|
48
|
+
validator = serializer_validator.view(view).version(v)
|
49
|
+
validator.override_suffix(:json) unless serializer_validated
|
50
|
+
|
51
|
+
serializer_output_registrations[view].register_block(
|
52
|
+
self,
|
53
|
+
validator,
|
54
|
+
v,
|
55
|
+
block,
|
56
|
+
false,
|
57
|
+
wildcards:
|
58
|
+
!serializer_disable_wildcards
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def output_raw(view: nil, version: nil, versions: nil, suffix: nil, &block)
|
64
|
+
versions = [version] if versions.nil?
|
65
|
+
raise VersionsNotAnArrayError unless versions.is_a? Array
|
66
|
+
|
67
|
+
raise ValidatorNotSpecifiedError, :output if serializer_validator.nil?
|
68
|
+
|
69
|
+
unless serializer_output_registrations.has_key? view
|
70
|
+
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
71
|
+
end
|
72
|
+
|
73
|
+
versions.each do |v|
|
74
|
+
validator = serializer_validator.view(view)
|
75
|
+
.version(v)
|
76
|
+
.override_suffix(suffix)
|
77
|
+
|
78
|
+
serializer_output_registrations[view].register_block(
|
79
|
+
self,
|
80
|
+
validator,
|
81
|
+
v,
|
82
|
+
block,
|
83
|
+
true,
|
84
|
+
wildcards: !serializer_disable_wildcards
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def output_alias(
|
90
|
+
media_type_identifier,
|
91
|
+
view: nil,
|
92
|
+
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil,
|
93
|
+
hide_variant: false
|
94
|
+
)
|
95
|
+
validator = serializer_validator.view(view).override_suffix(suffix)
|
96
|
+
victim_identifier = validator.identifier
|
97
|
+
|
98
|
+
unless serializer_output_registrations.has_key? view
|
99
|
+
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
100
|
+
end
|
101
|
+
|
102
|
+
serializer_output_registrations[view].register_alias(
|
103
|
+
self,
|
104
|
+
media_type_identifier,
|
105
|
+
victim_identifier,
|
106
|
+
false,
|
107
|
+
hide_variant,
|
108
|
+
wildcards: !serializer_disable_wildcards
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
def output_alias_optional(
|
113
|
+
media_type_identifier,
|
114
|
+
view: nil,
|
115
|
+
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil,
|
116
|
+
hide_variant: false
|
117
|
+
)
|
118
|
+
validator = serializer_validator.view(view).override_suffix(suffix)
|
119
|
+
victim_identifier = validator.identifier
|
120
|
+
|
121
|
+
unless serializer_output_registrations.has_key? view
|
122
|
+
serializer_output_registrations[view] = SerializationRegistration.new(:output)
|
123
|
+
end
|
124
|
+
|
125
|
+
serializer_output_registrations[view].register_alias(
|
126
|
+
self,
|
127
|
+
media_type_identifier,
|
128
|
+
victim_identifier,
|
129
|
+
true,
|
130
|
+
hide_variant,
|
131
|
+
wildcards: !serializer_disable_wildcards
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
def input(view: nil, version: nil, versions: nil, &block)
|
136
|
+
versions = [version] if versions.nil?
|
137
|
+
raise VersionsNotAnArrayError unless versions.is_a? Array
|
138
|
+
|
139
|
+
raise ValidatorNotSpecifiedError, :input if serializer_validator.nil?
|
140
|
+
|
141
|
+
unless serializer_input_registrations.has_key? view
|
142
|
+
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
143
|
+
end
|
144
|
+
|
145
|
+
versions.each do |v|
|
146
|
+
validator = serializer_validator.view(view).version(v)
|
147
|
+
validator.override_suffix(:json) unless serializer_validated
|
148
|
+
|
149
|
+
serializer_input_registrations[view].register_block(self, validator, v, block, false)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def input_raw(view: nil, version: nil, versions: nil, suffix: nil, &block)
|
154
|
+
versions = [version] if versions.nil?
|
155
|
+
raise VersionsNotAnArrayError unless versions.is_a? Array
|
156
|
+
|
157
|
+
raise ValidatorNotSpecifiedError, :input if serializer_validator.nil?
|
158
|
+
|
159
|
+
unless serializer_input_registrations.has_key? view
|
160
|
+
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
161
|
+
end
|
162
|
+
|
163
|
+
versions.each do |v|
|
164
|
+
validator = serializer_validator.view(view).version(v).override_suffix(suffix)
|
165
|
+
|
166
|
+
serializer_input_registrations[view].register_block(self, validator, v, block, true)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def input_alias(
|
171
|
+
media_type_identifier,
|
172
|
+
view: nil,
|
173
|
+
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil
|
174
|
+
)
|
175
|
+
validator = serializer_validator.view(view).override_suffix(suffix)
|
176
|
+
victim_identifier = validator.identifier
|
177
|
+
|
178
|
+
unless serializer_input_registrations.has_key? view
|
179
|
+
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
180
|
+
end
|
181
|
+
|
182
|
+
serializer_input_registrations[view].register_alias(
|
183
|
+
self,
|
184
|
+
media_type_identifier,
|
185
|
+
victim_identifier,
|
186
|
+
false,
|
187
|
+
true,
|
188
|
+
wildcards: false
|
189
|
+
)
|
190
|
+
end
|
191
|
+
|
192
|
+
def input_alias_optional(
|
193
|
+
media_type_identifier,
|
194
|
+
view: nil,
|
195
|
+
suffix: media_type_identifier == 'application/json' || media_type_identifier.end_with?('+json') ? :json : nil
|
196
|
+
)
|
197
|
+
validator = serializer_validator.view(view).override_suffix(suffix)
|
198
|
+
victim_identifier = validator.identifier
|
199
|
+
|
200
|
+
unless serializer_input_registrations.has_key? view
|
201
|
+
serializer_input_registrations[view] = SerializationRegistration.new(:input)
|
202
|
+
end
|
203
|
+
|
204
|
+
serializer_input_registrations[view].register_alias(
|
205
|
+
self,
|
206
|
+
media_type_identifier,
|
207
|
+
victim_identifier,
|
208
|
+
true,
|
209
|
+
true,
|
210
|
+
wildcards: false
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
def serialize(victim, media_type_identifier, context:, dsl: nil, raw: nil)
|
215
|
+
dsl ||= SerializationDSL.new(self, context: context)
|
216
|
+
|
217
|
+
merged_output_registrations = SerializationRegistration.new(:output)
|
218
|
+
serializer_output_registrations.keys.each do |k|
|
219
|
+
merged_output_registrations = merged_output_registrations.merge(serializer_output_registrations[k])
|
220
|
+
end
|
221
|
+
|
222
|
+
merged_output_registrations.call(victim, media_type_identifier.to_s, context, dsl: dsl, raw: raw)
|
223
|
+
end
|
224
|
+
|
225
|
+
def deserialize(victim, media_type_identifier, context:)
|
226
|
+
merged_input_registrations = SerializationRegistration.new(:input)
|
227
|
+
serializer_input_registrations.keys.each do |k|
|
228
|
+
merged_input_registrations = merged_input_registrations.merge(serializer_input_registrations[k])
|
229
|
+
end
|
230
|
+
|
231
|
+
merged_input_registrations.call(victim, media_type_identifier, context)
|
232
|
+
end
|
233
|
+
|
234
|
+
def outputs_for(views:)
|
235
|
+
merged_output_registrations = SerializationRegistration.new(:output)
|
236
|
+
views.each do |k|
|
237
|
+
merged_output_registrations = merged_output_registrations.merge(serializer_output_registrations[k]) if serializer_output_registrations.has_key?(k)
|
238
|
+
end
|
239
|
+
|
240
|
+
merged_output_registrations
|
241
|
+
end
|
242
|
+
|
243
|
+
def inputs_for(views:)
|
244
|
+
merged_input_registrations = SerializationRegistration.new(:input)
|
245
|
+
views.each do |k|
|
246
|
+
merged_input_registrations = merged_input_registrations.merge(serializer_input_registrations[k]) if serializer_input_registrations.has_key?(k)
|
247
|
+
end
|
248
|
+
|
249
|
+
merged_input_registrations
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def self.inherited(subclass)
|
254
|
+
super
|
255
|
+
|
256
|
+
subclass.extend(ClassMethods)
|
257
|
+
subclass.instance_eval do
|
258
|
+
class << self
|
259
|
+
attr_accessor :serializer_validated
|
260
|
+
attr_accessor :serializer_validator
|
261
|
+
attr_accessor :serializer_input_registrations
|
262
|
+
attr_accessor :serializer_output_registrations
|
263
|
+
attr_accessor :serializer_disable_wildcards
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|