hatchet-sdk 0.13.1 → 0.13.2
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/hatchet/clients/rest/.openapi-generator/FILES +10 -0
- data/lib/hatchet/clients/rest/README.md +15 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/sandbox_provider_api.rb +474 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_sandbox_provider_request.rb +393 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider.rb +486 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider_event.rb +374 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider_event_kind.rb +46 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider_event_list.rb +239 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider_kind.rb +44 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_sandbox_provider_status.rb +242 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_update_sandbox_provider_request.rb +329 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest.rb +10 -0
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet/worker/durable_event_listener.rb +7 -7
- metadata +12 -2
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Hatchet API
|
|
3
|
+
|
|
4
|
+
#The Hatchet API
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module HatchetSdkRest
|
|
17
|
+
class V1SandboxProvider
|
|
18
|
+
attr_accessor :metadata
|
|
19
|
+
|
|
20
|
+
attr_accessor :tenant_id
|
|
21
|
+
|
|
22
|
+
# The name of the provider. Unique within the tenant; the SDK selects it with metadata.provider.
|
|
23
|
+
attr_accessor :name
|
|
24
|
+
|
|
25
|
+
attr_accessor :kind
|
|
26
|
+
|
|
27
|
+
# Provider settings as JSON.
|
|
28
|
+
attr_accessor :config
|
|
29
|
+
|
|
30
|
+
# The longest idle time a sandbox may ask for before the sandbox provider removes it, in seconds.
|
|
31
|
+
attr_accessor :max_idle_ttl_seconds
|
|
32
|
+
|
|
33
|
+
# Default metadata for every sandbox this provider creates. The SDK's metadata overrides it key by key.
|
|
34
|
+
attr_accessor :labels
|
|
35
|
+
|
|
36
|
+
# Whether the operator serves sandboxes on this provider.
|
|
37
|
+
attr_accessor :enabled
|
|
38
|
+
|
|
39
|
+
attr_accessor :status
|
|
40
|
+
|
|
41
|
+
# The template or image a sandbox is created from when the SDK names none.
|
|
42
|
+
attr_accessor :default_template
|
|
43
|
+
|
|
44
|
+
class EnumAttributeValidator
|
|
45
|
+
attr_reader :datatype
|
|
46
|
+
attr_reader :allowable_values
|
|
47
|
+
|
|
48
|
+
def initialize(datatype, allowable_values)
|
|
49
|
+
@allowable_values = allowable_values.map do |value|
|
|
50
|
+
case datatype.to_s
|
|
51
|
+
when /Integer/i
|
|
52
|
+
value.to_i
|
|
53
|
+
when /Float/i
|
|
54
|
+
value.to_f
|
|
55
|
+
else
|
|
56
|
+
value
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def valid?(value)
|
|
62
|
+
!value || allowable_values.include?(value)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
67
|
+
def self.attribute_map
|
|
68
|
+
{
|
|
69
|
+
:'metadata' => :'metadata',
|
|
70
|
+
:'tenant_id' => :'tenantId',
|
|
71
|
+
:'name' => :'name',
|
|
72
|
+
:'kind' => :'kind',
|
|
73
|
+
:'config' => :'config',
|
|
74
|
+
:'max_idle_ttl_seconds' => :'maxIdleTtlSeconds',
|
|
75
|
+
:'labels' => :'labels',
|
|
76
|
+
:'enabled' => :'enabled',
|
|
77
|
+
:'status' => :'status',
|
|
78
|
+
:'default_template' => :'defaultTemplate'
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Returns attribute mapping this model knows about
|
|
83
|
+
def self.acceptable_attribute_map
|
|
84
|
+
attribute_map
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Returns all the JSON keys this model knows about
|
|
88
|
+
def self.acceptable_attributes
|
|
89
|
+
acceptable_attribute_map.values
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Attribute type mapping.
|
|
93
|
+
def self.openapi_types
|
|
94
|
+
{
|
|
95
|
+
:'metadata' => :'APIResourceMeta',
|
|
96
|
+
:'tenant_id' => :'String',
|
|
97
|
+
:'name' => :'String',
|
|
98
|
+
:'kind' => :'V1SandboxProviderKind',
|
|
99
|
+
:'config' => :'Hash<String, Object>',
|
|
100
|
+
:'max_idle_ttl_seconds' => :'Integer',
|
|
101
|
+
:'labels' => :'Hash<String, String>',
|
|
102
|
+
:'enabled' => :'Boolean',
|
|
103
|
+
:'status' => :'V1SandboxProviderStatus',
|
|
104
|
+
:'default_template' => :'String'
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# List of attributes with nullable: true
|
|
109
|
+
def self.openapi_nullable
|
|
110
|
+
Set.new([
|
|
111
|
+
])
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Initializes the object
|
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
116
|
+
def initialize(attributes = {})
|
|
117
|
+
if (!attributes.is_a?(Hash))
|
|
118
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::V1SandboxProvider` initialize method"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
122
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
123
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
124
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
125
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::V1SandboxProvider`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
126
|
+
end
|
|
127
|
+
h[k.to_sym] = v
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if attributes.key?(:'metadata')
|
|
131
|
+
self.metadata = attributes[:'metadata']
|
|
132
|
+
else
|
|
133
|
+
self.metadata = nil
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if attributes.key?(:'tenant_id')
|
|
137
|
+
self.tenant_id = attributes[:'tenant_id']
|
|
138
|
+
else
|
|
139
|
+
self.tenant_id = nil
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
if attributes.key?(:'name')
|
|
143
|
+
self.name = attributes[:'name']
|
|
144
|
+
else
|
|
145
|
+
self.name = nil
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
if attributes.key?(:'kind')
|
|
149
|
+
self.kind = attributes[:'kind']
|
|
150
|
+
else
|
|
151
|
+
self.kind = nil
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if attributes.key?(:'config')
|
|
155
|
+
if (value = attributes[:'config']).is_a?(Hash)
|
|
156
|
+
self.config = value
|
|
157
|
+
end
|
|
158
|
+
else
|
|
159
|
+
self.config = nil
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if attributes.key?(:'max_idle_ttl_seconds')
|
|
163
|
+
self.max_idle_ttl_seconds = attributes[:'max_idle_ttl_seconds']
|
|
164
|
+
else
|
|
165
|
+
self.max_idle_ttl_seconds = nil
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
if attributes.key?(:'labels')
|
|
169
|
+
if (value = attributes[:'labels']).is_a?(Hash)
|
|
170
|
+
self.labels = value
|
|
171
|
+
end
|
|
172
|
+
else
|
|
173
|
+
self.labels = nil
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
if attributes.key?(:'enabled')
|
|
177
|
+
self.enabled = attributes[:'enabled']
|
|
178
|
+
else
|
|
179
|
+
self.enabled = nil
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
if attributes.key?(:'status')
|
|
183
|
+
self.status = attributes[:'status']
|
|
184
|
+
else
|
|
185
|
+
self.status = nil
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
if attributes.key?(:'default_template')
|
|
189
|
+
self.default_template = attributes[:'default_template']
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
194
|
+
# @return Array for valid properties with the reasons
|
|
195
|
+
def list_invalid_properties
|
|
196
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
197
|
+
invalid_properties = Array.new
|
|
198
|
+
if @metadata.nil?
|
|
199
|
+
invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
if @tenant_id.nil?
|
|
203
|
+
invalid_properties.push('invalid value for "tenant_id", tenant_id cannot be nil.')
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
if @name.nil?
|
|
207
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
if @kind.nil?
|
|
211
|
+
invalid_properties.push('invalid value for "kind", kind cannot be nil.')
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
if @config.nil?
|
|
215
|
+
invalid_properties.push('invalid value for "config", config cannot be nil.')
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
if @max_idle_ttl_seconds.nil?
|
|
219
|
+
invalid_properties.push('invalid value for "max_idle_ttl_seconds", max_idle_ttl_seconds cannot be nil.')
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
if @labels.nil?
|
|
223
|
+
invalid_properties.push('invalid value for "labels", labels cannot be nil.')
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
if @enabled.nil?
|
|
227
|
+
invalid_properties.push('invalid value for "enabled", enabled cannot be nil.')
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
if @status.nil?
|
|
231
|
+
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
invalid_properties
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Check to see if the all the properties in the model are valid
|
|
238
|
+
# @return true if the model is valid
|
|
239
|
+
def valid?
|
|
240
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
241
|
+
return false if @metadata.nil?
|
|
242
|
+
return false if @tenant_id.nil?
|
|
243
|
+
return false if @name.nil?
|
|
244
|
+
return false if @kind.nil?
|
|
245
|
+
return false if @config.nil?
|
|
246
|
+
return false if @max_idle_ttl_seconds.nil?
|
|
247
|
+
return false if @labels.nil?
|
|
248
|
+
return false if @enabled.nil?
|
|
249
|
+
return false if @status.nil?
|
|
250
|
+
true
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Custom attribute writer method with validation
|
|
254
|
+
# @param [Object] metadata Value to be assigned
|
|
255
|
+
def metadata=(metadata)
|
|
256
|
+
if metadata.nil?
|
|
257
|
+
fail ArgumentError, 'metadata cannot be nil'
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
@metadata = metadata
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Custom attribute writer method with validation
|
|
264
|
+
# @param [Object] tenant_id Value to be assigned
|
|
265
|
+
def tenant_id=(tenant_id)
|
|
266
|
+
if tenant_id.nil?
|
|
267
|
+
fail ArgumentError, 'tenant_id cannot be nil'
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
@tenant_id = tenant_id
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Custom attribute writer method with validation
|
|
274
|
+
# @param [Object] name Value to be assigned
|
|
275
|
+
def name=(name)
|
|
276
|
+
if name.nil?
|
|
277
|
+
fail ArgumentError, 'name cannot be nil'
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
@name = name
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Custom attribute writer method with validation
|
|
284
|
+
# @param [Object] kind Value to be assigned
|
|
285
|
+
def kind=(kind)
|
|
286
|
+
if kind.nil?
|
|
287
|
+
fail ArgumentError, 'kind cannot be nil'
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
@kind = kind
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Custom attribute writer method with validation
|
|
294
|
+
# @param [Object] config Value to be assigned
|
|
295
|
+
def config=(config)
|
|
296
|
+
if config.nil?
|
|
297
|
+
fail ArgumentError, 'config cannot be nil'
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
@config = config
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Custom attribute writer method with validation
|
|
304
|
+
# @param [Object] max_idle_ttl_seconds Value to be assigned
|
|
305
|
+
def max_idle_ttl_seconds=(max_idle_ttl_seconds)
|
|
306
|
+
if max_idle_ttl_seconds.nil?
|
|
307
|
+
fail ArgumentError, 'max_idle_ttl_seconds cannot be nil'
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
@max_idle_ttl_seconds = max_idle_ttl_seconds
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Custom attribute writer method with validation
|
|
314
|
+
# @param [Object] labels Value to be assigned
|
|
315
|
+
def labels=(labels)
|
|
316
|
+
if labels.nil?
|
|
317
|
+
fail ArgumentError, 'labels cannot be nil'
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
@labels = labels
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Custom attribute writer method with validation
|
|
324
|
+
# @param [Object] enabled Value to be assigned
|
|
325
|
+
def enabled=(enabled)
|
|
326
|
+
if enabled.nil?
|
|
327
|
+
fail ArgumentError, 'enabled cannot be nil'
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
@enabled = enabled
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# Custom attribute writer method with validation
|
|
334
|
+
# @param [Object] status Value to be assigned
|
|
335
|
+
def status=(status)
|
|
336
|
+
if status.nil?
|
|
337
|
+
fail ArgumentError, 'status cannot be nil'
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
@status = status
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Checks equality by comparing each attribute.
|
|
344
|
+
# @param [Object] Object to be compared
|
|
345
|
+
def ==(o)
|
|
346
|
+
return true if self.equal?(o)
|
|
347
|
+
self.class == o.class &&
|
|
348
|
+
metadata == o.metadata &&
|
|
349
|
+
tenant_id == o.tenant_id &&
|
|
350
|
+
name == o.name &&
|
|
351
|
+
kind == o.kind &&
|
|
352
|
+
config == o.config &&
|
|
353
|
+
max_idle_ttl_seconds == o.max_idle_ttl_seconds &&
|
|
354
|
+
labels == o.labels &&
|
|
355
|
+
enabled == o.enabled &&
|
|
356
|
+
status == o.status &&
|
|
357
|
+
default_template == o.default_template
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# @see the `==` method
|
|
361
|
+
# @param [Object] Object to be compared
|
|
362
|
+
def eql?(o)
|
|
363
|
+
self == o
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# Calculates hash code according to all attributes.
|
|
367
|
+
# @return [Integer] Hash code
|
|
368
|
+
def hash
|
|
369
|
+
[metadata, tenant_id, name, kind, config, max_idle_ttl_seconds, labels, enabled, status, default_template].hash
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Builds the object from hash
|
|
373
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
374
|
+
# @return [Object] Returns the model itself
|
|
375
|
+
def self.build_from_hash(attributes)
|
|
376
|
+
return nil unless attributes.is_a?(Hash)
|
|
377
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
378
|
+
transformed_hash = {}
|
|
379
|
+
openapi_types.each_pair do |key, type|
|
|
380
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
381
|
+
transformed_hash["#{key}"] = nil
|
|
382
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
383
|
+
# check to ensure the input is an array given that the attribute
|
|
384
|
+
# is documented as an array but the input is not
|
|
385
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
386
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
387
|
+
end
|
|
388
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
389
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
new(transformed_hash)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Deserializes the data based on type
|
|
396
|
+
# @param string type Data type
|
|
397
|
+
# @param string value Value to be deserialized
|
|
398
|
+
# @return [Object] Deserialized data
|
|
399
|
+
def self._deserialize(type, value)
|
|
400
|
+
case type.to_sym
|
|
401
|
+
when :Time
|
|
402
|
+
Time.parse(value)
|
|
403
|
+
when :Date
|
|
404
|
+
Date.parse(value)
|
|
405
|
+
when :String
|
|
406
|
+
value.to_s
|
|
407
|
+
when :Integer
|
|
408
|
+
value.to_i
|
|
409
|
+
when :Float
|
|
410
|
+
value.to_f
|
|
411
|
+
when :Boolean
|
|
412
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
413
|
+
true
|
|
414
|
+
else
|
|
415
|
+
false
|
|
416
|
+
end
|
|
417
|
+
when :Object
|
|
418
|
+
# generic object (usually a Hash), return directly
|
|
419
|
+
value
|
|
420
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
421
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
422
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
423
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
424
|
+
k_type = Regexp.last_match[:k_type]
|
|
425
|
+
v_type = Regexp.last_match[:v_type]
|
|
426
|
+
{}.tap do |hash|
|
|
427
|
+
value.each do |k, v|
|
|
428
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
429
|
+
end
|
|
430
|
+
end
|
|
431
|
+
else # model
|
|
432
|
+
# models (e.g. Pet) or oneOf
|
|
433
|
+
klass = HatchetSdkRest.const_get(type)
|
|
434
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
# Returns the string representation of the object
|
|
439
|
+
# @return [String] String presentation of the object
|
|
440
|
+
def to_s
|
|
441
|
+
to_hash.to_s
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
445
|
+
# @return [Hash] Returns the object in the form of hash
|
|
446
|
+
def to_body
|
|
447
|
+
to_hash
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
# Returns the object in the form of hash
|
|
451
|
+
# @return [Hash] Returns the object in the form of hash
|
|
452
|
+
def to_hash
|
|
453
|
+
hash = {}
|
|
454
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
455
|
+
value = self.send(attr)
|
|
456
|
+
if value.nil?
|
|
457
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
458
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
hash[param] = _to_hash(value)
|
|
462
|
+
end
|
|
463
|
+
hash
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
# Outputs non-array value in the form of hash
|
|
467
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
468
|
+
# @param [Object] value Any valid value
|
|
469
|
+
# @return [Hash] Returns the value in the form of hash
|
|
470
|
+
def _to_hash(value)
|
|
471
|
+
if value.is_a?(Array)
|
|
472
|
+
value.compact.map { |v| _to_hash(v) }
|
|
473
|
+
elsif value.is_a?(Hash)
|
|
474
|
+
{}.tap do |hash|
|
|
475
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
476
|
+
end
|
|
477
|
+
elsif value.respond_to? :to_hash
|
|
478
|
+
value.to_hash
|
|
479
|
+
else
|
|
480
|
+
value
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
end
|