pulpcore_client 3.42.0 → 3.43.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,53 +15,53 @@ require 'date'
15
15
  module PulpcoreClient
16
16
  # A serializer for ArtifactDistribution.
17
17
  class ArtifactDistributionResponse
18
- # Timestamp of creation.
19
- attr_accessor :pulp_created
18
+ # Whether this distribution should be shown in the content app.
19
+ attr_accessor :hidden
20
20
 
21
21
  attr_accessor :pulp_labels
22
22
 
23
+ # The URL for accessing the publication as defined by this distribution.
24
+ attr_accessor :base_url
25
+
26
+ # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
27
+ attr_accessor :base_path
28
+
23
29
  # A unique name. Ex, `rawhide` and `stable`.
24
30
  attr_accessor :name
25
31
 
26
- # Whether this distribution should be shown in the content app.
27
- attr_accessor :hidden
32
+ # Timestamp of creation.
33
+ attr_accessor :pulp_created
28
34
 
29
35
  # An optional content-guard.
30
36
  attr_accessor :content_guard
31
37
 
32
38
  attr_accessor :pulp_href
33
39
 
34
- # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
35
- attr_accessor :base_path
36
-
37
- # The URL for accessing the publication as defined by this distribution.
38
- attr_accessor :base_url
39
-
40
40
  # Attribute mapping from ruby-style variable name to JSON key.
41
41
  def self.attribute_map
42
42
  {
43
- :'pulp_created' => :'pulp_created',
43
+ :'hidden' => :'hidden',
44
44
  :'pulp_labels' => :'pulp_labels',
45
+ :'base_url' => :'base_url',
46
+ :'base_path' => :'base_path',
45
47
  :'name' => :'name',
46
- :'hidden' => :'hidden',
48
+ :'pulp_created' => :'pulp_created',
47
49
  :'content_guard' => :'content_guard',
48
- :'pulp_href' => :'pulp_href',
49
- :'base_path' => :'base_path',
50
- :'base_url' => :'base_url'
50
+ :'pulp_href' => :'pulp_href'
51
51
  }
52
52
  end
53
53
 
54
54
  # Attribute type mapping.
55
55
  def self.openapi_types
56
56
  {
57
- :'pulp_created' => :'DateTime',
57
+ :'hidden' => :'Boolean',
58
58
  :'pulp_labels' => :'Hash<String, String>',
59
+ :'base_url' => :'String',
60
+ :'base_path' => :'String',
59
61
  :'name' => :'String',
60
- :'hidden' => :'Boolean',
62
+ :'pulp_created' => :'DateTime',
61
63
  :'content_guard' => :'String',
62
- :'pulp_href' => :'String',
63
- :'base_path' => :'String',
64
- :'base_url' => :'String'
64
+ :'pulp_href' => :'String'
65
65
  }
66
66
  end
67
67
 
@@ -87,8 +87,10 @@ module PulpcoreClient
87
87
  h[k.to_sym] = v
88
88
  }
89
89
 
90
- if attributes.key?(:'pulp_created')
91
- self.pulp_created = attributes[:'pulp_created']
90
+ if attributes.key?(:'hidden')
91
+ self.hidden = attributes[:'hidden']
92
+ else
93
+ self.hidden = false
92
94
  end
93
95
 
94
96
  if attributes.key?(:'pulp_labels')
@@ -97,14 +99,20 @@ module PulpcoreClient
97
99
  end
98
100
  end
99
101
 
102
+ if attributes.key?(:'base_url')
103
+ self.base_url = attributes[:'base_url']
104
+ end
105
+
106
+ if attributes.key?(:'base_path')
107
+ self.base_path = attributes[:'base_path']
108
+ end
109
+
100
110
  if attributes.key?(:'name')
101
111
  self.name = attributes[:'name']
102
112
  end
103
113
 
104
- if attributes.key?(:'hidden')
105
- self.hidden = attributes[:'hidden']
106
- else
107
- self.hidden = false
114
+ if attributes.key?(:'pulp_created')
115
+ self.pulp_created = attributes[:'pulp_created']
108
116
  end
109
117
 
110
118
  if attributes.key?(:'content_guard')
@@ -114,36 +122,28 @@ module PulpcoreClient
114
122
  if attributes.key?(:'pulp_href')
115
123
  self.pulp_href = attributes[:'pulp_href']
116
124
  end
117
-
118
- if attributes.key?(:'base_path')
119
- self.base_path = attributes[:'base_path']
120
- end
121
-
122
- if attributes.key?(:'base_url')
123
- self.base_url = attributes[:'base_url']
124
- end
125
125
  end
126
126
 
127
127
  # Show invalid properties with the reasons. Usually used together with valid?
128
128
  # @return Array for valid properties with the reasons
129
129
  def list_invalid_properties
130
130
  invalid_properties = Array.new
131
- if @name.nil?
132
- invalid_properties.push('invalid value for "name", name cannot be nil.')
133
- end
134
-
135
131
  if @base_path.nil?
136
132
  invalid_properties.push('invalid value for "base_path", base_path cannot be nil.')
137
133
  end
138
134
 
135
+ if @name.nil?
136
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
137
+ end
138
+
139
139
  invalid_properties
140
140
  end
141
141
 
142
142
  # Check to see if the all the properties in the model are valid
143
143
  # @return true if the model is valid
144
144
  def valid?
145
- return false if @name.nil?
146
145
  return false if @base_path.nil?
146
+ return false if @name.nil?
147
147
  true
148
148
  end
149
149
 
@@ -152,14 +152,14 @@ module PulpcoreClient
152
152
  def ==(o)
153
153
  return true if self.equal?(o)
154
154
  self.class == o.class &&
155
- pulp_created == o.pulp_created &&
155
+ hidden == o.hidden &&
156
156
  pulp_labels == o.pulp_labels &&
157
+ base_url == o.base_url &&
158
+ base_path == o.base_path &&
157
159
  name == o.name &&
158
- hidden == o.hidden &&
160
+ pulp_created == o.pulp_created &&
159
161
  content_guard == o.content_guard &&
160
- pulp_href == o.pulp_href &&
161
- base_path == o.base_path &&
162
- base_url == o.base_url
162
+ pulp_href == o.pulp_href
163
163
  end
164
164
 
165
165
  # @see the `==` method
@@ -171,7 +171,7 @@ module PulpcoreClient
171
171
  # Calculates hash code according to all attributes.
172
172
  # @return [Integer] Hash code
173
173
  def hash
174
- [pulp_created, pulp_labels, name, hidden, content_guard, pulp_href, base_path, base_url].hash
174
+ [hidden, pulp_labels, base_url, base_path, name, pulp_created, content_guard, pulp_href].hash
175
175
  end
176
176
 
177
177
  # Builds the object from hash
@@ -0,0 +1,270 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #Fetch, Upload, Organize, and Distribute Software Packages
5
+
6
+ The version of the OpenAPI document: v3
7
+ Contact: pulp-list@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpcoreClient
16
+ # Base serializer for use with :class:`pulpcore.app.models.Model` This ensures that all Serializers provide values for the 'pulp_href` field. The class provides a default for the ``ref_name`` attribute in the ModelSerializers's ``Meta`` class. This ensures that the OpenAPI definitions of plugins are namespaced properly.
17
+ class CompositeContentGuard
18
+ # The unique name.
19
+ attr_accessor :name
20
+
21
+ # An optional description.
22
+ attr_accessor :description
23
+
24
+ # List of ContentGuards to ask for access-permission.
25
+ attr_accessor :guards
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'name' => :'name',
31
+ :'description' => :'description',
32
+ :'guards' => :'guards'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'name' => :'String',
40
+ :'description' => :'String',
41
+ :'guards' => :'Array<String>'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ :'description',
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::CompositeContentGuard` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::CompositeContentGuard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'name')
68
+ self.name = attributes[:'name']
69
+ end
70
+
71
+ if attributes.key?(:'description')
72
+ self.description = attributes[:'description']
73
+ end
74
+
75
+ if attributes.key?(:'guards')
76
+ if (value = attributes[:'guards']).is_a?(Array)
77
+ self.guards = value
78
+ end
79
+ end
80
+ end
81
+
82
+ # Show invalid properties with the reasons. Usually used together with valid?
83
+ # @return Array for valid properties with the reasons
84
+ def list_invalid_properties
85
+ invalid_properties = Array.new
86
+ if @name.nil?
87
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
88
+ end
89
+
90
+ if @name.to_s.length < 1
91
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
92
+ end
93
+
94
+ if !@description.nil? && @description.to_s.length < 1
95
+ invalid_properties.push('invalid value for "description", the character length must be great than or equal to 1.')
96
+ end
97
+
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ return false if @name.nil?
105
+ return false if @name.to_s.length < 1
106
+ return false if !@description.nil? && @description.to_s.length < 1
107
+ true
108
+ end
109
+
110
+ # Custom attribute writer method with validation
111
+ # @param [Object] name Value to be assigned
112
+ def name=(name)
113
+ if name.nil?
114
+ fail ArgumentError, 'name cannot be nil'
115
+ end
116
+
117
+ if name.to_s.length < 1
118
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
119
+ end
120
+
121
+ @name = name
122
+ end
123
+
124
+ # Custom attribute writer method with validation
125
+ # @param [Object] description Value to be assigned
126
+ def description=(description)
127
+ if !description.nil? && description.to_s.length < 1
128
+ fail ArgumentError, 'invalid value for "description", the character length must be great than or equal to 1.'
129
+ end
130
+
131
+ @description = description
132
+ end
133
+
134
+ # Checks equality by comparing each attribute.
135
+ # @param [Object] Object to be compared
136
+ def ==(o)
137
+ return true if self.equal?(o)
138
+ self.class == o.class &&
139
+ name == o.name &&
140
+ description == o.description &&
141
+ guards == o.guards
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [name, description, guards].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ new.build_from_hash(attributes)
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ self.class.openapi_types.each_pair do |key, type|
169
+ if type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
173
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :DateTime
190
+ DateTime.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ PulpcoreClient.const_get(type).build_from_hash(value)
221
+ end
222
+ end
223
+
224
+ # Returns the string representation of the object
225
+ # @return [String] String presentation of the object
226
+ def to_s
227
+ to_hash.to_s
228
+ end
229
+
230
+ # to_body is an alias to to_hash (backward compatibility)
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_body
233
+ to_hash
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = self.send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+ end
270
+ end
@@ -0,0 +1,255 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #Fetch, Upload, Organize, and Distribute Software Packages
5
+
6
+ The version of the OpenAPI document: v3
7
+ Contact: pulp-list@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpcoreClient
16
+ # Base serializer for use with :class:`pulpcore.app.models.Model` This ensures that all Serializers provide values for the 'pulp_href` field. The class provides a default for the ``ref_name`` attribute in the ModelSerializers's ``Meta`` class. This ensures that the OpenAPI definitions of plugins are namespaced properly.
17
+ class CompositeContentGuardResponse
18
+ attr_accessor :pulp_href
19
+
20
+ # Timestamp of creation.
21
+ attr_accessor :pulp_created
22
+
23
+ # The unique name.
24
+ attr_accessor :name
25
+
26
+ # An optional description.
27
+ attr_accessor :description
28
+
29
+ # List of ContentGuards to ask for access-permission.
30
+ attr_accessor :guards
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'pulp_href' => :'pulp_href',
36
+ :'pulp_created' => :'pulp_created',
37
+ :'name' => :'name',
38
+ :'description' => :'description',
39
+ :'guards' => :'guards'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'pulp_href' => :'String',
47
+ :'pulp_created' => :'DateTime',
48
+ :'name' => :'String',
49
+ :'description' => :'String',
50
+ :'guards' => :'Array<String>'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ :'description',
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::CompositeContentGuardResponse` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::CompositeContentGuardResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'pulp_href')
77
+ self.pulp_href = attributes[:'pulp_href']
78
+ end
79
+
80
+ if attributes.key?(:'pulp_created')
81
+ self.pulp_created = attributes[:'pulp_created']
82
+ end
83
+
84
+ if attributes.key?(:'name')
85
+ self.name = attributes[:'name']
86
+ end
87
+
88
+ if attributes.key?(:'description')
89
+ self.description = attributes[:'description']
90
+ end
91
+
92
+ if attributes.key?(:'guards')
93
+ if (value = attributes[:'guards']).is_a?(Array)
94
+ self.guards = value
95
+ end
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ if @name.nil?
104
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
105
+ end
106
+
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ return false if @name.nil?
114
+ true
115
+ end
116
+
117
+ # Checks equality by comparing each attribute.
118
+ # @param [Object] Object to be compared
119
+ def ==(o)
120
+ return true if self.equal?(o)
121
+ self.class == o.class &&
122
+ pulp_href == o.pulp_href &&
123
+ pulp_created == o.pulp_created &&
124
+ name == o.name &&
125
+ description == o.description &&
126
+ guards == o.guards
127
+ end
128
+
129
+ # @see the `==` method
130
+ # @param [Object] Object to be compared
131
+ def eql?(o)
132
+ self == o
133
+ end
134
+
135
+ # Calculates hash code according to all attributes.
136
+ # @return [Integer] Hash code
137
+ def hash
138
+ [pulp_href, pulp_created, name, description, guards].hash
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def self.build_from_hash(attributes)
145
+ new.build_from_hash(attributes)
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+ self.class.openapi_types.each_pair do |key, type|
154
+ if type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :DateTime
175
+ DateTime.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ PulpcoreClient.const_get(type).build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+ end
255
+ end