pulpcore_client 3.4.0.dev01590527325 → 3.4.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 +4 -4
- data/README.md +15 -9
- data/docs/{Artifact.md → ArtifactRead.md} +2 -2
- data/docs/ArtifactsApi.md +4 -4
- data/docs/ExportersCoreExportsApi.md +2 -2
- data/docs/ExportersPulpApi.md +8 -8
- data/docs/{Import.md → ImportRead.md} +2 -2
- data/docs/ImportersCoreImportsApi.md +2 -2
- data/docs/ImportersPulpApi.md +8 -8
- data/docs/InlineResponse200.md +1 -1
- data/docs/InlineResponse2001.md +1 -1
- data/docs/InlineResponse2002.md +1 -1
- data/docs/InlineResponse2003.md +1 -1
- data/docs/InlineResponse2004.md +1 -1
- data/docs/InlineResponse2005.md +1 -1
- data/docs/InlineResponse2006.md +1 -1
- data/docs/InlineResponse2007.md +1 -1
- data/docs/InlineResponse2008.md +1 -1
- data/docs/InlineResponse2009.md +1 -1
- data/docs/PulpExport.md +8 -0
- data/docs/PulpExportRead.md +27 -0
- data/docs/PulpExporterRead.md +27 -0
- data/docs/PulpImporterRead.md +23 -0
- data/docs/{SigningService.md → SigningServiceRead.md} +2 -2
- data/docs/SigningServicesApi.md +2 -2
- data/docs/{TaskGroup.md → TaskGroupRead.md} +2 -2
- data/docs/TaskGroupsApi.md +2 -2
- data/docs/TaskRead.md +43 -0
- data/docs/TasksApi.md +2 -2
- data/docs/{UploadDetail.md → UploadDetailRead.md} +2 -2
- data/docs/UploadRead.md +23 -0
- data/docs/UploadsApi.md +4 -4
- data/docs/Worker.md +3 -3
- data/docs/WorkerRead.md +23 -0
- data/docs/WorkersApi.md +2 -2
- data/lib/pulpcore_client.rb +11 -5
- data/lib/pulpcore_client/api/artifacts_api.rb +6 -6
- data/lib/pulpcore_client/api/exporters_core_exports_api.rb +3 -3
- data/lib/pulpcore_client/api/exporters_pulp_api.rb +12 -12
- data/lib/pulpcore_client/api/importers_core_imports_api.rb +3 -3
- data/lib/pulpcore_client/api/importers_pulp_api.rb +12 -12
- data/lib/pulpcore_client/api/signing_services_api.rb +3 -3
- data/lib/pulpcore_client/api/task_groups_api.rb +3 -3
- data/lib/pulpcore_client/api/tasks_api.rb +3 -3
- data/lib/pulpcore_client/api/uploads_api.rb +6 -6
- data/lib/pulpcore_client/api/workers_api.rb +3 -3
- data/lib/pulpcore_client/models/{artifact.rb → artifact_read.rb} +3 -3
- data/lib/pulpcore_client/models/{import.rb → import_read.rb} +3 -3
- data/lib/pulpcore_client/models/inline_response200.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2001.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2002.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2003.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2004.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2005.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2006.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2007.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2008.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2009.rb +1 -1
- data/lib/pulpcore_client/models/pulp_export.rb +62 -1
- data/lib/pulpcore_client/models/pulp_export_read.rb +259 -0
- data/lib/pulpcore_client/models/pulp_exporter_read.rb +311 -0
- data/lib/pulpcore_client/models/pulp_importer_read.rb +262 -0
- data/lib/pulpcore_client/models/{signing_service.rb → signing_service_read.rb} +3 -3
- data/lib/pulpcore_client/models/{task_group.rb → task_group_read.rb} +3 -3
- data/lib/pulpcore_client/models/task_read.rb +383 -0
- data/lib/pulpcore_client/models/{upload_detail.rb → upload_detail_read.rb} +3 -3
- data/lib/pulpcore_client/models/upload_read.rb +241 -0
- data/lib/pulpcore_client/models/worker.rb +10 -10
- data/lib/pulpcore_client/models/worker_read.rb +251 -0
- data/lib/pulpcore_client/version.rb +1 -1
- data/spec/api/artifacts_api_spec.rb +2 -2
- data/spec/api/exporters_core_exports_api_spec.rb +1 -1
- data/spec/api/exporters_pulp_api_spec.rb +4 -4
- data/spec/api/importers_core_imports_api_spec.rb +1 -1
- data/spec/api/importers_pulp_api_spec.rb +4 -4
- data/spec/api/signing_services_api_spec.rb +1 -1
- data/spec/api/task_groups_api_spec.rb +1 -1
- data/spec/api/tasks_api_spec.rb +1 -1
- data/spec/api/uploads_api_spec.rb +2 -2
- data/spec/api/workers_api_spec.rb +1 -1
- data/spec/models/{artifact_spec.rb → artifact_read_spec.rb} +6 -6
- data/spec/models/{import_spec.rb → import_read_spec.rb} +6 -6
- data/spec/models/pulp_export_read_spec.rb +71 -0
- data/spec/models/pulp_export_spec.rb +24 -0
- data/spec/models/pulp_exporter_read_spec.rb +71 -0
- data/spec/models/pulp_importer_read_spec.rb +59 -0
- data/spec/models/{signing_service_spec.rb → signing_service_read_spec.rb} +6 -6
- data/spec/models/{task_group_spec.rb → task_group_read_spec.rb} +6 -6
- data/spec/models/task_read_spec.rb +119 -0
- data/spec/models/{upload_detail_spec.rb → upload_detail_read_spec.rb} +6 -6
- data/spec/models/upload_read_spec.rb +59 -0
- data/spec/models/worker_read_spec.rb +59 -0
- data/spec/models/worker_spec.rb +2 -2
- metadata +48 -24
|
@@ -28,6 +28,18 @@ module PulpcoreClient
|
|
|
28
28
|
# Any additional parameters that were used to create the export.
|
|
29
29
|
attr_accessor :params
|
|
30
30
|
|
|
31
|
+
# Do a Full (true) or Incremental (false) export.
|
|
32
|
+
attr_accessor :full
|
|
33
|
+
|
|
34
|
+
# Generate report on what would be exported and disk-space required.
|
|
35
|
+
attr_accessor :dry_run
|
|
36
|
+
|
|
37
|
+
# List of explicit repo-version hrefs to export
|
|
38
|
+
attr_accessor :versions
|
|
39
|
+
|
|
40
|
+
# Chunk export-tarfile into pieces of chunk_size bytes.Recognizes units of B/KB/MB/GB/TB.
|
|
41
|
+
attr_accessor :chunk_size
|
|
42
|
+
|
|
31
43
|
# Dictionary of filename: sha256hash entries for export-output-file(s)
|
|
32
44
|
attr_accessor :output_file_info
|
|
33
45
|
|
|
@@ -39,6 +51,10 @@ module PulpcoreClient
|
|
|
39
51
|
:'task' => :'task',
|
|
40
52
|
:'exported_resources' => :'exported_resources',
|
|
41
53
|
:'params' => :'params',
|
|
54
|
+
:'full' => :'full',
|
|
55
|
+
:'dry_run' => :'dry_run',
|
|
56
|
+
:'versions' => :'versions',
|
|
57
|
+
:'chunk_size' => :'chunk_size',
|
|
42
58
|
:'output_file_info' => :'output_file_info'
|
|
43
59
|
}
|
|
44
60
|
end
|
|
@@ -51,6 +67,10 @@ module PulpcoreClient
|
|
|
51
67
|
:'task' => :'String',
|
|
52
68
|
:'exported_resources' => :'Array<Object>',
|
|
53
69
|
:'params' => :'Object',
|
|
70
|
+
:'full' => :'Boolean',
|
|
71
|
+
:'dry_run' => :'Boolean',
|
|
72
|
+
:'versions' => :'Array<String>',
|
|
73
|
+
:'chunk_size' => :'String',
|
|
54
74
|
:'output_file_info' => :'Object'
|
|
55
75
|
}
|
|
56
76
|
end
|
|
@@ -99,6 +119,28 @@ module PulpcoreClient
|
|
|
99
119
|
self.params = attributes[:'params']
|
|
100
120
|
end
|
|
101
121
|
|
|
122
|
+
if attributes.key?(:'full')
|
|
123
|
+
self.full = attributes[:'full']
|
|
124
|
+
else
|
|
125
|
+
self.full = true
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if attributes.key?(:'dry_run')
|
|
129
|
+
self.dry_run = attributes[:'dry_run']
|
|
130
|
+
else
|
|
131
|
+
self.dry_run = false
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
if attributes.key?(:'versions')
|
|
135
|
+
if (value = attributes[:'versions']).is_a?(Array)
|
|
136
|
+
self.versions = value
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if attributes.key?(:'chunk_size')
|
|
141
|
+
self.chunk_size = attributes[:'chunk_size']
|
|
142
|
+
end
|
|
143
|
+
|
|
102
144
|
if attributes.key?(:'output_file_info')
|
|
103
145
|
self.output_file_info = attributes[:'output_file_info']
|
|
104
146
|
end
|
|
@@ -108,15 +150,30 @@ module PulpcoreClient
|
|
|
108
150
|
# @return Array for valid properties with the reasons
|
|
109
151
|
def list_invalid_properties
|
|
110
152
|
invalid_properties = Array.new
|
|
153
|
+
if !@chunk_size.nil? && @chunk_size.to_s.length < 1
|
|
154
|
+
invalid_properties.push('invalid value for "chunk_size", the character length must be great than or equal to 1.')
|
|
155
|
+
end
|
|
156
|
+
|
|
111
157
|
invalid_properties
|
|
112
158
|
end
|
|
113
159
|
|
|
114
160
|
# Check to see if the all the properties in the model are valid
|
|
115
161
|
# @return true if the model is valid
|
|
116
162
|
def valid?
|
|
163
|
+
return false if !@chunk_size.nil? && @chunk_size.to_s.length < 1
|
|
117
164
|
true
|
|
118
165
|
end
|
|
119
166
|
|
|
167
|
+
# Custom attribute writer method with validation
|
|
168
|
+
# @param [Object] chunk_size Value to be assigned
|
|
169
|
+
def chunk_size=(chunk_size)
|
|
170
|
+
if !chunk_size.nil? && chunk_size.to_s.length < 1
|
|
171
|
+
fail ArgumentError, 'invalid value for "chunk_size", the character length must be great than or equal to 1.'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
@chunk_size = chunk_size
|
|
175
|
+
end
|
|
176
|
+
|
|
120
177
|
# Checks equality by comparing each attribute.
|
|
121
178
|
# @param [Object] Object to be compared
|
|
122
179
|
def ==(o)
|
|
@@ -127,6 +184,10 @@ module PulpcoreClient
|
|
|
127
184
|
task == o.task &&
|
|
128
185
|
exported_resources == o.exported_resources &&
|
|
129
186
|
params == o.params &&
|
|
187
|
+
full == o.full &&
|
|
188
|
+
dry_run == o.dry_run &&
|
|
189
|
+
versions == o.versions &&
|
|
190
|
+
chunk_size == o.chunk_size &&
|
|
130
191
|
output_file_info == o.output_file_info
|
|
131
192
|
end
|
|
132
193
|
|
|
@@ -139,7 +200,7 @@ module PulpcoreClient
|
|
|
139
200
|
# Calculates hash code according to all attributes.
|
|
140
201
|
# @return [Integer] Hash code
|
|
141
202
|
def hash
|
|
142
|
-
[pulp_href, pulp_created, task, exported_resources, params, output_file_info].hash
|
|
203
|
+
[pulp_href, pulp_created, task, exported_resources, params, full, dry_run, versions, chunk_size, output_file_info].hash
|
|
143
204
|
end
|
|
144
205
|
|
|
145
206
|
# Builds the object from hash
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Pulp 3 API
|
|
3
|
+
|
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: v3
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
OpenAPI Generator version: 4.2.3
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
|
|
15
|
+
module PulpcoreClient
|
|
16
|
+
class PulpExportRead
|
|
17
|
+
attr_accessor :pulp_href
|
|
18
|
+
|
|
19
|
+
# Timestamp of creation.
|
|
20
|
+
attr_accessor :pulp_created
|
|
21
|
+
|
|
22
|
+
# A URI of the task that ran the Export.
|
|
23
|
+
attr_accessor :task
|
|
24
|
+
|
|
25
|
+
# Resources that were exported.
|
|
26
|
+
attr_accessor :exported_resources
|
|
27
|
+
|
|
28
|
+
# Any additional parameters that were used to create the export.
|
|
29
|
+
attr_accessor :params
|
|
30
|
+
|
|
31
|
+
# Dictionary of filename: sha256hash entries for export-output-file(s)
|
|
32
|
+
attr_accessor :output_file_info
|
|
33
|
+
|
|
34
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
35
|
+
def self.attribute_map
|
|
36
|
+
{
|
|
37
|
+
:'pulp_href' => :'pulp_href',
|
|
38
|
+
:'pulp_created' => :'pulp_created',
|
|
39
|
+
:'task' => :'task',
|
|
40
|
+
:'exported_resources' => :'exported_resources',
|
|
41
|
+
:'params' => :'params',
|
|
42
|
+
:'output_file_info' => :'output_file_info'
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Attribute type mapping.
|
|
47
|
+
def self.openapi_types
|
|
48
|
+
{
|
|
49
|
+
:'pulp_href' => :'String',
|
|
50
|
+
:'pulp_created' => :'DateTime',
|
|
51
|
+
:'task' => :'String',
|
|
52
|
+
:'exported_resources' => :'Array<Object>',
|
|
53
|
+
:'params' => :'Object',
|
|
54
|
+
:'output_file_info' => :'Object'
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# List of attributes with nullable: true
|
|
59
|
+
def self.openapi_nullable
|
|
60
|
+
Set.new([
|
|
61
|
+
:'task',
|
|
62
|
+
])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Initializes the object
|
|
66
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
67
|
+
def initialize(attributes = {})
|
|
68
|
+
if (!attributes.is_a?(Hash))
|
|
69
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::PulpExportRead` initialize method"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
73
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
74
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
75
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::PulpExportRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
76
|
+
end
|
|
77
|
+
h[k.to_sym] = v
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if attributes.key?(:'pulp_href')
|
|
81
|
+
self.pulp_href = attributes[:'pulp_href']
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if attributes.key?(:'pulp_created')
|
|
85
|
+
self.pulp_created = attributes[:'pulp_created']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if attributes.key?(:'task')
|
|
89
|
+
self.task = attributes[:'task']
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if attributes.key?(:'exported_resources')
|
|
93
|
+
if (value = attributes[:'exported_resources']).is_a?(Array)
|
|
94
|
+
self.exported_resources = value
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if attributes.key?(:'params')
|
|
99
|
+
self.params = attributes[:'params']
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
if attributes.key?(:'output_file_info')
|
|
103
|
+
self.output_file_info = attributes[:'output_file_info']
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
108
|
+
# @return Array for valid properties with the reasons
|
|
109
|
+
def list_invalid_properties
|
|
110
|
+
invalid_properties = Array.new
|
|
111
|
+
invalid_properties
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Check to see if the all the properties in the model are valid
|
|
115
|
+
# @return true if the model is valid
|
|
116
|
+
def valid?
|
|
117
|
+
true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Checks equality by comparing each attribute.
|
|
121
|
+
# @param [Object] Object to be compared
|
|
122
|
+
def ==(o)
|
|
123
|
+
return true if self.equal?(o)
|
|
124
|
+
self.class == o.class &&
|
|
125
|
+
pulp_href == o.pulp_href &&
|
|
126
|
+
pulp_created == o.pulp_created &&
|
|
127
|
+
task == o.task &&
|
|
128
|
+
exported_resources == o.exported_resources &&
|
|
129
|
+
params == o.params &&
|
|
130
|
+
output_file_info == o.output_file_info
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# @see the `==` method
|
|
134
|
+
# @param [Object] Object to be compared
|
|
135
|
+
def eql?(o)
|
|
136
|
+
self == o
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Calculates hash code according to all attributes.
|
|
140
|
+
# @return [Integer] Hash code
|
|
141
|
+
def hash
|
|
142
|
+
[pulp_href, pulp_created, task, exported_resources, params, output_file_info].hash
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Builds the object from hash
|
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
147
|
+
# @return [Object] Returns the model itself
|
|
148
|
+
def self.build_from_hash(attributes)
|
|
149
|
+
new.build_from_hash(attributes)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Builds the object from hash
|
|
153
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
154
|
+
# @return [Object] Returns the model itself
|
|
155
|
+
def build_from_hash(attributes)
|
|
156
|
+
return nil unless attributes.is_a?(Hash)
|
|
157
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
158
|
+
if type =~ /\AArray<(.*)>/i
|
|
159
|
+
# check to ensure the input is an array given that the attribute
|
|
160
|
+
# is documented as an array but the input is not
|
|
161
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
162
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
163
|
+
end
|
|
164
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
165
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
166
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
self
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Deserializes the data based on type
|
|
173
|
+
# @param string type Data type
|
|
174
|
+
# @param string value Value to be deserialized
|
|
175
|
+
# @return [Object] Deserialized data
|
|
176
|
+
def _deserialize(type, value)
|
|
177
|
+
case type.to_sym
|
|
178
|
+
when :DateTime
|
|
179
|
+
DateTime.parse(value)
|
|
180
|
+
when :Date
|
|
181
|
+
Date.parse(value)
|
|
182
|
+
when :String
|
|
183
|
+
value.to_s
|
|
184
|
+
when :Integer
|
|
185
|
+
value.to_i
|
|
186
|
+
when :Float
|
|
187
|
+
value.to_f
|
|
188
|
+
when :Boolean
|
|
189
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
190
|
+
true
|
|
191
|
+
else
|
|
192
|
+
false
|
|
193
|
+
end
|
|
194
|
+
when :Object
|
|
195
|
+
# generic object (usually a Hash), return directly
|
|
196
|
+
value
|
|
197
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
198
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
199
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
200
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
201
|
+
k_type = Regexp.last_match[:k_type]
|
|
202
|
+
v_type = Regexp.last_match[:v_type]
|
|
203
|
+
{}.tap do |hash|
|
|
204
|
+
value.each do |k, v|
|
|
205
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
else # model
|
|
209
|
+
PulpcoreClient.const_get(type).build_from_hash(value)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Returns the string representation of the object
|
|
214
|
+
# @return [String] String presentation of the object
|
|
215
|
+
def to_s
|
|
216
|
+
to_hash.to_s
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
220
|
+
# @return [Hash] Returns the object in the form of hash
|
|
221
|
+
def to_body
|
|
222
|
+
to_hash
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Returns the object in the form of hash
|
|
226
|
+
# @return [Hash] Returns the object in the form of hash
|
|
227
|
+
def to_hash
|
|
228
|
+
hash = {}
|
|
229
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
230
|
+
value = self.send(attr)
|
|
231
|
+
if value.nil?
|
|
232
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
233
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
hash[param] = _to_hash(value)
|
|
237
|
+
end
|
|
238
|
+
hash
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Outputs non-array value in the form of hash
|
|
242
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
243
|
+
# @param [Object] value Any valid value
|
|
244
|
+
# @return [Hash] Returns the value in the form of hash
|
|
245
|
+
def _to_hash(value)
|
|
246
|
+
if value.is_a?(Array)
|
|
247
|
+
value.compact.map { |v| _to_hash(v) }
|
|
248
|
+
elsif value.is_a?(Hash)
|
|
249
|
+
{}.tap do |hash|
|
|
250
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
251
|
+
end
|
|
252
|
+
elsif value.respond_to? :to_hash
|
|
253
|
+
value.to_hash
|
|
254
|
+
else
|
|
255
|
+
value
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|