mux_ruby 3.0.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +4 -4
  4. data/docs/Asset.md +1 -1
  5. data/docs/AssetsApi.md +73 -0
  6. data/docs/CreateAssetRequest.md +1 -1
  7. data/docs/CreateLiveStreamRequest.md +4 -2
  8. data/docs/CreatePlaybackRestrictionRequest.md +18 -0
  9. data/docs/CreateSimulcastTargetRequest.md +1 -1
  10. data/docs/CreateTrackRequest.md +1 -1
  11. data/docs/DeliveryUsageApi.md +4 -2
  12. data/docs/DimensionsApi.md +4 -4
  13. data/docs/ErrorsApi.md +4 -4
  14. data/docs/FiltersApi.md +4 -4
  15. data/docs/InputSettings.md +1 -1
  16. data/docs/ListPlaybackRestrictionsResponse.md +18 -0
  17. data/docs/LiveStream.md +8 -4
  18. data/docs/LiveStreamEmbeddedSubtitleSettings.md +1 -1
  19. data/docs/LiveStreamStatus.md +15 -0
  20. data/docs/LiveStreamsApi.md +76 -1
  21. data/docs/MetricsApi.md +21 -21
  22. data/docs/PlaybackRestriction.md +24 -0
  23. data/docs/PlaybackRestrictionResponse.md +18 -0
  24. data/docs/PlaybackRestrictionsApi.md +367 -0
  25. data/docs/RealTimeApi.md +6 -6
  26. data/docs/ReferrerDomainRestriction.md +20 -0
  27. data/docs/SimulcastTarget.md +1 -1
  28. data/docs/Track.md +1 -1
  29. data/docs/UpdateAssetRequest.md +18 -0
  30. data/docs/UpdateLiveStreamRequest.md +22 -0
  31. data/docs/UpdateReferrerDomainRestrictionRequest.md +15 -0
  32. data/docs/VideoViewsApi.md +4 -4
  33. data/examples/data/exercise-errors.rb +0 -1
  34. data/gen/generator-config.json +1 -1
  35. data/lib/mux_ruby/api/assets_api.rb +71 -0
  36. data/lib/mux_ruby/api/delivery_usage_api.rb +5 -2
  37. data/lib/mux_ruby/api/dimensions_api.rb +4 -4
  38. data/lib/mux_ruby/api/errors_api.rb +4 -4
  39. data/lib/mux_ruby/api/filters_api.rb +4 -4
  40. data/lib/mux_ruby/api/live_streams_api.rb +74 -0
  41. data/lib/mux_ruby/api/metrics_api.rb +22 -22
  42. data/lib/mux_ruby/api/playback_restrictions_api.rb +345 -0
  43. data/lib/mux_ruby/api/real_time_api.rb +6 -6
  44. data/lib/mux_ruby/api/video_views_api.rb +4 -4
  45. data/lib/mux_ruby/models/asset.rb +1 -1
  46. data/lib/mux_ruby/models/create_asset_request.rb +1 -1
  47. data/lib/mux_ruby/models/create_live_stream_request.rb +47 -3
  48. data/lib/mux_ruby/models/create_playback_restriction_request.rb +218 -0
  49. data/lib/mux_ruby/models/create_simulcast_target_request.rb +1 -1
  50. data/lib/mux_ruby/models/create_track_request.rb +1 -1
  51. data/lib/mux_ruby/models/input_settings.rb +1 -1
  52. data/lib/mux_ruby/models/input_settings_overlay_settings.rb +1 -1
  53. data/lib/mux_ruby/models/list_playback_restrictions_response.rb +220 -0
  54. data/lib/mux_ruby/models/live_stream.rb +35 -14
  55. data/lib/mux_ruby/models/live_stream_embedded_subtitle_settings.rb +1 -1
  56. data/lib/mux_ruby/models/live_stream_status.rb +38 -0
  57. data/lib/mux_ruby/models/playback_restriction.rb +248 -0
  58. data/lib/mux_ruby/models/playback_restriction_response.rb +218 -0
  59. data/lib/mux_ruby/models/referrer_domain_restriction.rb +234 -0
  60. data/lib/mux_ruby/models/simulcast_target.rb +1 -1
  61. data/lib/mux_ruby/models/track.rb +1 -1
  62. data/lib/mux_ruby/models/update_asset_request.rb +219 -0
  63. data/lib/mux_ruby/models/update_live_stream_request.rb +297 -0
  64. data/lib/mux_ruby/models/update_referrer_domain_restriction_request.rb +209 -0
  65. data/lib/mux_ruby/version.rb +1 -1
  66. data/lib/mux_ruby.rb +10 -0
  67. data/spec/api/playback_restrictions_api_spec.rb +97 -0
  68. data/spec/models/create_playback_restriction_request_spec.rb +34 -0
  69. data/spec/models/list_playback_restrictions_response_spec.rb +34 -0
  70. data/spec/models/live_stream_status_spec.rb +28 -0
  71. data/spec/models/playback_restriction_response_spec.rb +28 -0
  72. data/spec/models/playback_restriction_spec.rb +52 -0
  73. data/spec/models/referrer_domain_restriction_spec.rb +40 -0
  74. data/spec/models/update_asset_request_spec.rb +34 -0
  75. data/spec/models/update_live_stream_request_spec.rb +50 -0
  76. data/spec/models/update_referrer_domain_restriction_request_spec.rb +28 -0
  77. metadata +135 -95
@@ -51,7 +51,7 @@ module MuxRuby
51
51
  # Indicates the track provides Subtitles for the Deaf or Hard-of-hearing (SDH). This parameter is set for the `text` type and `subtitles` text type track.
52
52
  attr_accessor :closed_captions
53
53
 
54
- # Arbitrary metadata set for the track either when creating the asset or track. This parameter is set for `text` type and `subtitles` text type track. Max 255 characters.
54
+ # Arbitrary user-supplied metadata set for the track either when creating the asset or track. This parameter is set for `text` type and `subtitles` text type track. Max 255 characters.
55
55
  attr_accessor :passthrough
56
56
 
57
57
  class EnumAttributeValidator
@@ -0,0 +1,219 @@
1
+ =begin
2
+ #Mux API
3
+
4
+ #Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: devex@mux.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MuxRuby
17
+ class UpdateAssetRequest
18
+ # Arbitrary metadata set for the Asset. Max 255 characters. In order to clear this value, the field should be included with an empty string value.
19
+ attr_accessor :passthrough
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'passthrough' => :'passthrough'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'passthrough' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::UpdateAssetRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::UpdateAssetRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'passthrough')
62
+ self.passthrough = attributes[:'passthrough']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ passthrough == o.passthrough
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [passthrough].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
113
+ self.send("#{key}=", nil)
114
+ elsif type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ end
123
+ end
124
+
125
+ self
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def _deserialize(type, value)
133
+ case type.to_sym
134
+ when :Time
135
+ Time.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ # models (e.g. Pet) or oneOf
166
+ klass = MuxRuby.const_get(type)
167
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+
219
+ end
@@ -0,0 +1,297 @@
1
+ =begin
2
+ #Mux API
3
+
4
+ #Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: devex@mux.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MuxRuby
17
+ class UpdateLiveStreamRequest
18
+ # Arbitrary user-supplied metadata set for the live stream. Max 255 characters. In order to clear this value, the field should be included with an empty-string value.
19
+ attr_accessor :passthrough
20
+
21
+ # Latency is the time from when the streamer transmits a frame of video to when you see it in the player. Set this as an alternative to setting low latency or reduced latency flags. The Low Latency value is a beta feature. Note: Reconnect windows are incompatible with Reduced Latency and Low Latency and will always be set to zero (0) seconds. Read more here: https://mux.com/blog/introducing-low-latency-live-streaming/
22
+ attr_accessor :latency_mode
23
+
24
+ # When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset.
25
+ attr_accessor :reconnect_window
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'passthrough' => :'passthrough',
53
+ :'latency_mode' => :'latency_mode',
54
+ :'reconnect_window' => :'reconnect_window'
55
+ }
56
+ end
57
+
58
+ # Returns all the JSON keys this model knows about
59
+ def self.acceptable_attributes
60
+ attribute_map.values
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'passthrough' => :'String',
67
+ :'latency_mode' => :'String',
68
+ :'reconnect_window' => :'Float'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::UpdateLiveStreamRequest` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::UpdateLiveStreamRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'passthrough')
94
+ self.passthrough = attributes[:'passthrough']
95
+ end
96
+
97
+ if attributes.key?(:'latency_mode')
98
+ self.latency_mode = attributes[:'latency_mode']
99
+ end
100
+
101
+ if attributes.key?(:'reconnect_window')
102
+ self.reconnect_window = attributes[:'reconnect_window']
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if !@reconnect_window.nil? && @reconnect_window > 300
111
+ invalid_properties.push('invalid value for "reconnect_window", must be smaller than or equal to 300.')
112
+ end
113
+
114
+ if !@reconnect_window.nil? && @reconnect_window < 0.1
115
+ invalid_properties.push('invalid value for "reconnect_window", must be greater than or equal to 0.1.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ latency_mode_validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
125
+ return false unless latency_mode_validator.valid?(@latency_mode)
126
+ return false if !@reconnect_window.nil? && @reconnect_window > 300
127
+ return false if !@reconnect_window.nil? && @reconnect_window < 0.1
128
+ true
129
+ end
130
+
131
+ # Custom attribute writer method checking allowed values (enum).
132
+ # @param [Object] latency_mode Object to be assigned
133
+ def latency_mode=(latency_mode)
134
+ validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
135
+ unless validator.valid?(latency_mode)
136
+ fail ArgumentError, "invalid value for \"latency_mode\", must be one of #{validator.allowable_values}."
137
+ end
138
+ @latency_mode = latency_mode
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] reconnect_window Value to be assigned
143
+ def reconnect_window=(reconnect_window)
144
+ if !reconnect_window.nil? && reconnect_window > 300
145
+ fail ArgumentError, 'invalid value for "reconnect_window", must be smaller than or equal to 300.'
146
+ end
147
+
148
+ if !reconnect_window.nil? && reconnect_window < 0.1
149
+ fail ArgumentError, 'invalid value for "reconnect_window", must be greater than or equal to 0.1.'
150
+ end
151
+
152
+ @reconnect_window = reconnect_window
153
+ end
154
+
155
+ # Checks equality by comparing each attribute.
156
+ # @param [Object] Object to be compared
157
+ def ==(o)
158
+ return true if self.equal?(o)
159
+ self.class == o.class &&
160
+ passthrough == o.passthrough &&
161
+ latency_mode == o.latency_mode &&
162
+ reconnect_window == o.reconnect_window
163
+ end
164
+
165
+ # @see the `==` method
166
+ # @param [Object] Object to be compared
167
+ def eql?(o)
168
+ self == o
169
+ end
170
+
171
+ # Calculates hash code according to all attributes.
172
+ # @return [Integer] Hash code
173
+ def hash
174
+ [passthrough, latency_mode, reconnect_window].hash
175
+ end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def self.build_from_hash(attributes)
181
+ new.build_from_hash(attributes)
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ self.class.openapi_types.each_pair do |key, type|
190
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
191
+ self.send("#{key}=", nil)
192
+ elsif type =~ /\AArray<(.*)>/i
193
+ # check to ensure the input is an array given that the attribute
194
+ # is documented as an array but the input is not
195
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
196
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
197
+ end
198
+ elsif !attributes[self.class.attribute_map[key]].nil?
199
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
200
+ end
201
+ end
202
+
203
+ self
204
+ end
205
+
206
+ # Deserializes the data based on type
207
+ # @param string type Data type
208
+ # @param string value Value to be deserialized
209
+ # @return [Object] Deserialized data
210
+ def _deserialize(type, value)
211
+ case type.to_sym
212
+ when :Time
213
+ Time.parse(value)
214
+ when :Date
215
+ Date.parse(value)
216
+ when :String
217
+ value.to_s
218
+ when :Integer
219
+ value.to_i
220
+ when :Float
221
+ value.to_f
222
+ when :Boolean
223
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
224
+ true
225
+ else
226
+ false
227
+ end
228
+ when :Object
229
+ # generic object (usually a Hash), return directly
230
+ value
231
+ when /\AArray<(?<inner_type>.+)>\z/
232
+ inner_type = Regexp.last_match[:inner_type]
233
+ value.map { |v| _deserialize(inner_type, v) }
234
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
235
+ k_type = Regexp.last_match[:k_type]
236
+ v_type = Regexp.last_match[:v_type]
237
+ {}.tap do |hash|
238
+ value.each do |k, v|
239
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
240
+ end
241
+ end
242
+ else # model
243
+ # models (e.g. Pet) or oneOf
244
+ klass = MuxRuby.const_get(type)
245
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
246
+ end
247
+ end
248
+
249
+ # Returns the string representation of the object
250
+ # @return [String] String presentation of the object
251
+ def to_s
252
+ to_hash.to_s
253
+ end
254
+
255
+ # to_body is an alias to to_hash (backward compatibility)
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_body
258
+ to_hash
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = self.send(attr)
267
+ if value.nil?
268
+ is_nullable = self.class.openapi_nullable.include?(attr)
269
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
270
+ end
271
+
272
+ hash[param] = _to_hash(value)
273
+ end
274
+ hash
275
+ end
276
+
277
+ # Outputs non-array value in the form of hash
278
+ # For object, use to_hash. Otherwise, just return the value
279
+ # @param [Object] value Any valid value
280
+ # @return [Hash] Returns the value in the form of hash
281
+ def _to_hash(value)
282
+ if value.is_a?(Array)
283
+ value.compact.map { |v| _to_hash(v) }
284
+ elsif value.is_a?(Hash)
285
+ {}.tap do |hash|
286
+ value.each { |k, v| hash[k] = _to_hash(v) }
287
+ end
288
+ elsif value.respond_to? :to_hash
289
+ value.to_hash
290
+ else
291
+ value
292
+ end
293
+ end
294
+
295
+ end
296
+
297
+ end