ff-ruby-server-sdk 0.0.2 → 1.0.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.run/sdk_test.rb.run.xml +3 -3
  3. data/CHANGELOG.md +12 -2
  4. data/Gemfile +17 -3
  5. data/README.md +155 -7
  6. data/api.yaml +736 -0
  7. data/example/example.rb +100 -3
  8. data/lib/ff/ruby/server/generated/lib/openapi_client/api/client_api.rb +545 -0
  9. data/lib/ff/ruby/server/generated/lib/openapi_client/api/metrics_api.rb +89 -0
  10. data/lib/ff/ruby/server/generated/lib/openapi_client/api_client.rb +390 -0
  11. data/lib/ff/ruby/server/generated/lib/openapi_client/api_error.rb +57 -0
  12. data/lib/ff/ruby/server/generated/lib/openapi_client/configuration.rb +282 -0
  13. data/lib/ff/ruby/server/generated/lib/openapi_client/models/authentication_request.rb +232 -0
  14. data/lib/ff/ruby/server/generated/lib/openapi_client/models/authentication_request_target.rb +250 -0
  15. data/lib/ff/ruby/server/generated/lib/openapi_client/models/authentication_response.rb +223 -0
  16. data/lib/ff/ruby/server/generated/lib/openapi_client/models/clause.rb +281 -0
  17. data/lib/ff/ruby/server/generated/lib/openapi_client/models/distribution.rb +239 -0
  18. data/lib/ff/ruby/server/generated/lib/openapi_client/models/error.rb +237 -0
  19. data/lib/ff/ruby/server/generated/lib/openapi_client/models/evaluation.rb +260 -0
  20. data/lib/ff/ruby/server/generated/lib/openapi_client/models/feature_config.rb +418 -0
  21. data/lib/ff/ruby/server/generated/lib/openapi_client/models/feature_state.rb +37 -0
  22. data/lib/ff/ruby/server/generated/lib/openapi_client/models/key_value.rb +237 -0
  23. data/lib/ff/ruby/server/generated/lib/openapi_client/models/metrics.rb +231 -0
  24. data/lib/ff/ruby/server/generated/lib/openapi_client/models/metrics_data.rb +303 -0
  25. data/lib/ff/ruby/server/generated/lib/openapi_client/models/pagination.rb +274 -0
  26. data/lib/ff/ruby/server/generated/lib/openapi_client/models/prerequisite.rb +239 -0
  27. data/lib/ff/ruby/server/generated/lib/openapi_client/models/segment.rb +320 -0
  28. data/lib/ff/ruby/server/generated/lib/openapi_client/models/serve.rb +227 -0
  29. data/lib/ff/ruby/server/generated/lib/openapi_client/models/serving_rule.rb +267 -0
  30. data/lib/ff/ruby/server/generated/lib/openapi_client/models/tag.rb +233 -0
  31. data/lib/ff/ruby/server/generated/lib/openapi_client/models/target.rb +331 -0
  32. data/lib/ff/ruby/server/generated/lib/openapi_client/models/target_data.rb +253 -0
  33. data/lib/ff/ruby/server/generated/lib/openapi_client/models/target_map.rb +232 -0
  34. data/lib/ff/ruby/server/generated/lib/openapi_client/models/variation.rb +255 -0
  35. data/lib/ff/ruby/server/generated/lib/openapi_client/models/variation_map.rb +245 -0
  36. data/lib/ff/ruby/server/generated/lib/openapi_client/models/weighted_variation.rb +237 -0
  37. data/lib/ff/ruby/server/generated/lib/openapi_client/version.rb +15 -0
  38. data/lib/ff/ruby/server/generated/lib/openapi_client.rb +65 -0
  39. data/lib/ff/ruby/server/sdk/api/auth_service.rb +91 -0
  40. data/lib/ff/ruby/server/sdk/api/cf_client.rb +93 -0
  41. data/lib/ff/ruby/server/sdk/api/client_callback.rb +45 -0
  42. data/lib/ff/ruby/server/sdk/api/config.rb +140 -0
  43. data/lib/ff/ruby/server/sdk/api/config_builder.rb +116 -0
  44. data/lib/ff/ruby/server/sdk/api/default_cache.rb +112 -0
  45. data/lib/ff/ruby/server/sdk/api/evaluation.rb +29 -0
  46. data/lib/ff/ruby/server/sdk/api/evaluator.rb +526 -0
  47. data/lib/ff/ruby/server/sdk/api/file_map_store.rb +60 -0
  48. data/lib/ff/ruby/server/sdk/api/flag_evaluate_callback.rb +13 -0
  49. data/lib/ff/ruby/server/sdk/api/inner_client.rb +311 -0
  50. data/lib/ff/ruby/server/sdk/api/inner_client_flag_evaluate_callback.rb +30 -0
  51. data/lib/ff/ruby/server/sdk/api/inner_client_metrics_callback.rb +33 -0
  52. data/lib/ff/ruby/server/sdk/api/inner_client_repository_callback.rb +44 -0
  53. data/lib/ff/ruby/server/sdk/api/inner_client_updater.rb +63 -0
  54. data/lib/ff/ruby/server/sdk/api/metrics_callback.rb +19 -0
  55. data/lib/ff/ruby/server/sdk/api/metrics_event.rb +16 -0
  56. data/lib/ff/ruby/server/sdk/api/metrics_processor.rb +297 -0
  57. data/lib/ff/ruby/server/sdk/api/operators.rb +20 -0
  58. data/lib/ff/ruby/server/sdk/api/polling_processor.rb +164 -0
  59. data/lib/ff/ruby/server/sdk/api/repository_callback.rb +28 -0
  60. data/lib/ff/ruby/server/sdk/api/storage_repository.rb +263 -0
  61. data/lib/ff/ruby/server/sdk/api/summary_metrics.rb +16 -0
  62. data/lib/ff/ruby/server/sdk/api/update_processor.rb +149 -0
  63. data/lib/ff/ruby/server/sdk/common/cache.rb +27 -0
  64. data/lib/ff/ruby/server/sdk/common/closeable.rb +7 -0
  65. data/lib/ff/ruby/server/sdk/common/destroyable.rb +12 -0
  66. data/lib/ff/ruby/server/sdk/common/repository.rb +45 -0
  67. data/lib/ff/ruby/server/sdk/common/storage.rb +29 -0
  68. data/lib/ff/ruby/server/sdk/connector/connector.rb +44 -0
  69. data/lib/ff/ruby/server/sdk/connector/events.rb +118 -0
  70. data/lib/ff/ruby/server/sdk/connector/harness_connector.rb +236 -0
  71. data/lib/ff/ruby/server/sdk/connector/service.rb +19 -0
  72. data/lib/ff/ruby/server/sdk/connector/updater.rb +32 -0
  73. data/lib/ff/ruby/server/sdk/dto/message.rb +13 -0
  74. data/lib/ff/ruby/server/sdk/dto/target.rb +24 -0
  75. data/lib/ff/ruby/server/sdk/version.rb +2 -1
  76. data/lib/ff/ruby/server/sdk.rb +39 -3
  77. data/openapitools.json +7 -0
  78. data/scripts/install.sh +8 -2
  79. data/scripts/openapi.sh +76 -0
  80. data/scripts/publish.sh +1 -1
  81. data/scripts/sdk_specs.sh +1 -1
  82. metadata +263 -11
  83. data/lib/ff/ruby/server/sdk/cf_client.rb +0 -6
@@ -0,0 +1,274 @@
1
+ =begin
2
+ #Harness feature flag service client apis
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: cf@harness.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class Pagination
18
+ attr_accessor :version
19
+
20
+ attr_accessor :page_count
21
+
22
+ attr_accessor :item_count
23
+
24
+ attr_accessor :page_size
25
+
26
+ attr_accessor :page_index
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'version' => :'version',
32
+ :'page_count' => :'pageCount',
33
+ :'item_count' => :'itemCount',
34
+ :'page_size' => :'pageSize',
35
+ :'page_index' => :'pageIndex'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'version' => :'Integer',
48
+ :'page_count' => :'Integer',
49
+ :'item_count' => :'Integer',
50
+ :'page_size' => :'Integer',
51
+ :'page_index' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
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 `OpenapiClient::Pagination` 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 `OpenapiClient::Pagination`. 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?(:'version')
77
+ self.version = attributes[:'version']
78
+ end
79
+
80
+ if attributes.key?(:'page_count')
81
+ self.page_count = attributes[:'page_count']
82
+ end
83
+
84
+ if attributes.key?(:'item_count')
85
+ self.item_count = attributes[:'item_count']
86
+ end
87
+
88
+ if attributes.key?(:'page_size')
89
+ self.page_size = attributes[:'page_size']
90
+ end
91
+
92
+ if attributes.key?(:'page_index')
93
+ self.page_index = attributes[:'page_index']
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ invalid_properties = Array.new
101
+ if @page_count.nil?
102
+ invalid_properties.push('invalid value for "page_count", page_count cannot be nil.')
103
+ end
104
+
105
+ if @item_count.nil?
106
+ invalid_properties.push('invalid value for "item_count", item_count cannot be nil.')
107
+ end
108
+
109
+ if @page_size.nil?
110
+ invalid_properties.push('invalid value for "page_size", page_size cannot be nil.')
111
+ end
112
+
113
+ if @page_index.nil?
114
+ invalid_properties.push('invalid value for "page_index", page_index cannot be nil.')
115
+ end
116
+
117
+ invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ return false if @page_count.nil?
124
+ return false if @item_count.nil?
125
+ return false if @page_size.nil?
126
+ return false if @page_index.nil?
127
+ true
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ version == o.version &&
136
+ page_count == o.page_count &&
137
+ item_count == o.item_count &&
138
+ page_size == o.page_size &&
139
+ page_index == o.page_index
140
+ end
141
+
142
+ # @see the `==` method
143
+ # @param [Object] Object to be compared
144
+ def eql?(o)
145
+ self == o
146
+ end
147
+
148
+ # Calculates hash code according to all attributes.
149
+ # @return [Integer] Hash code
150
+ def hash
151
+ [version, page_count, item_count, page_size, page_index].hash
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def self.build_from_hash(attributes)
158
+ new.build_from_hash(attributes)
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ self.class.openapi_types.each_pair do |key, type|
167
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
168
+ self.send("#{key}=", nil)
169
+ elsif 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
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 :Time
190
+ Time.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
+ # models (e.g. Pet) or oneOf
221
+ klass = OpenapiClient.const_get(type)
222
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+
272
+ end
273
+
274
+ end
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #Harness feature flag service client apis
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: cf@harness.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class Prerequisite
18
+ attr_accessor :feature
19
+
20
+ attr_accessor :variations
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'feature' => :'feature',
26
+ :'variations' => :'variations'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'feature' => :'String',
39
+ :'variations' => :'Array<String>'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Prerequisite` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Prerequisite`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'feature')
65
+ self.feature = attributes[:'feature']
66
+ end
67
+
68
+ if attributes.key?(:'variations')
69
+ if (value = attributes[:'variations']).is_a?(Array)
70
+ self.variations = value
71
+ end
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ invalid_properties = Array.new
79
+ if @feature.nil?
80
+ invalid_properties.push('invalid value for "feature", feature cannot be nil.')
81
+ end
82
+
83
+ if @variations.nil?
84
+ invalid_properties.push('invalid value for "variations", variations cannot be nil.')
85
+ end
86
+
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ return false if @feature.nil?
94
+ return false if @variations.nil?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ feature == o.feature &&
104
+ variations == o.variations
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [feature, variations].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ new.build_from_hash(attributes)
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
+ self.send("#{key}=", nil)
134
+ elsif type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
138
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ end
140
+ elsif !attributes[self.class.attribute_map[key]].nil?
141
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ end
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = OpenapiClient.const_get(type)
187
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end