triglav_client 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/Gemfile.lock +79 -0
  4. data/LICENSE +201 -0
  5. data/README.md +136 -0
  6. data/Rakefile +1 -0
  7. data/docs/AggregatedResourceEachResponse.md +11 -0
  8. data/docs/AuthApi.md +150 -0
  9. data/docs/BulkinsertResponse.md +8 -0
  10. data/docs/Credential.md +10 -0
  11. data/docs/ErrorModel.md +9 -0
  12. data/docs/JobEachResponse.md +12 -0
  13. data/docs/JobMessageEachResponse.md +11 -0
  14. data/docs/JobMessagesApi.md +117 -0
  15. data/docs/JobRequest.md +12 -0
  16. data/docs/JobResponse.md +14 -0
  17. data/docs/JobsApi.md +217 -0
  18. data/docs/LastJobMessageIdResponse.md +8 -0
  19. data/docs/LastMessageIdResponse.md +8 -0
  20. data/docs/MessageEachResponse.md +16 -0
  21. data/docs/MessageFetchRequest.md +10 -0
  22. data/docs/MessageRequest.md +13 -0
  23. data/docs/MessageResponse.md +16 -0
  24. data/docs/MessagesApi.md +170 -0
  25. data/docs/ResourceEachResponse.md +13 -0
  26. data/docs/ResourceRequest.md +15 -0
  27. data/docs/ResourceResponse.md +17 -0
  28. data/docs/ResourcesApi.md +335 -0
  29. data/docs/TokenResponse.md +9 -0
  30. data/docs/UserEachResponse.md +11 -0
  31. data/docs/UserRequest.md +13 -0
  32. data/docs/UserResponse.md +15 -0
  33. data/docs/UsersApi.md +274 -0
  34. data/example/example.rb +40 -0
  35. data/git_push.sh +67 -0
  36. data/lib/triglav_client.rb +77 -0
  37. data/lib/triglav_client/api/auth_api.rb +196 -0
  38. data/lib/triglav_client/api/job_messages_api.rb +153 -0
  39. data/lib/triglav_client/api/jobs_api.rb +257 -0
  40. data/lib/triglav_client/api/messages_api.rb +208 -0
  41. data/lib/triglav_client/api/resources_api.rb +379 -0
  42. data/lib/triglav_client/api/users_api.rb +318 -0
  43. data/lib/triglav_client/api_client.rb +379 -0
  44. data/lib/triglav_client/api_error.rb +47 -0
  45. data/lib/triglav_client/configuration.rb +214 -0
  46. data/lib/triglav_client/models/aggregated_resource_each_response.rb +230 -0
  47. data/lib/triglav_client/models/bulkinsert_response.rb +200 -0
  48. data/lib/triglav_client/models/credential.rb +252 -0
  49. data/lib/triglav_client/models/error_model.rb +212 -0
  50. data/lib/triglav_client/models/job_each_response.rb +235 -0
  51. data/lib/triglav_client/models/job_message_each_response.rb +229 -0
  52. data/lib/triglav_client/models/job_request.rb +241 -0
  53. data/lib/triglav_client/models/job_response.rb +259 -0
  54. data/lib/triglav_client/models/last_job_message_id_response.rb +200 -0
  55. data/lib/triglav_client/models/last_message_id_response.rb +200 -0
  56. data/lib/triglav_client/models/message_each_response.rb +281 -0
  57. data/lib/triglav_client/models/message_fetch_request.rb +223 -0
  58. data/lib/triglav_client/models/message_request.rb +254 -0
  59. data/lib/triglav_client/models/message_response.rb +281 -0
  60. data/lib/triglav_client/models/resource_each_response.rb +250 -0
  61. data/lib/triglav_client/models/resource_request.rb +269 -0
  62. data/lib/triglav_client/models/resource_response.rb +287 -0
  63. data/lib/triglav_client/models/token_response.rb +208 -0
  64. data/lib/triglav_client/models/user_each_response.rb +262 -0
  65. data/lib/triglav_client/models/user_request.rb +280 -0
  66. data/lib/triglav_client/models/user_response.rb +300 -0
  67. data/lib/triglav_client/version.rb +26 -0
  68. data/spec/api/auth_api_spec.rb +80 -0
  69. data/spec/api/job_messages_api_spec.rb +71 -0
  70. data/spec/api/jobs_api_spec.rb +93 -0
  71. data/spec/api/messages_api_spec.rb +74 -0
  72. data/spec/api/resources_api_spec.rb +109 -0
  73. data/spec/api/users_api_spec.rb +106 -0
  74. data/spec/api_client_spec.rb +237 -0
  75. data/spec/configuration_spec.rb +53 -0
  76. data/spec/models/aggregated_resource_each_response_spec.rb +71 -0
  77. data/spec/models/bulkinsert_response_spec.rb +53 -0
  78. data/spec/models/credential_spec.rb +69 -0
  79. data/spec/models/error_model_spec.rb +59 -0
  80. data/spec/models/job_each_response_spec.rb +77 -0
  81. data/spec/models/job_message_each_response_spec.rb +65 -0
  82. data/spec/models/job_request_spec.rb +71 -0
  83. data/spec/models/job_response_spec.rb +89 -0
  84. data/spec/models/last_job_message_id_response_spec.rb +53 -0
  85. data/spec/models/last_message_id_response_spec.rb +53 -0
  86. data/spec/models/message_each_response_spec.rb +89 -0
  87. data/spec/models/message_fetch_request_spec.rb +65 -0
  88. data/spec/models/message_request_spec.rb +59 -0
  89. data/spec/models/message_response_spec.rb +89 -0
  90. data/spec/models/resource_each_response_spec.rb +71 -0
  91. data/spec/models/resource_request_spec.rb +83 -0
  92. data/spec/models/resource_response_spec.rb +101 -0
  93. data/spec/models/token_response_spec.rb +59 -0
  94. data/spec/models/user_each_response_spec.rb +75 -0
  95. data/spec/models/user_request_spec.rb +87 -0
  96. data/spec/models/user_response_spec.rb +99 -0
  97. data/spec/spec_helper.rb +122 -0
  98. data/triglav_client.gemspec +55 -0
  99. metadata +351 -0
@@ -0,0 +1,280 @@
1
+ =begin
2
+ #Triglav API
3
+
4
+ #Triglav API
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: triglav_admin_my@dena.jp
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module TriglavClient
27
+
28
+ class UserRequest
29
+ attr_accessor :name
30
+
31
+ attr_accessor :description
32
+
33
+ # local or ldap
34
+ attr_accessor :authenticator
35
+
36
+ attr_accessor :groups
37
+
38
+ attr_accessor :email
39
+
40
+ attr_accessor :password
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'name' => :'name',
68
+ :'description' => :'description',
69
+ :'authenticator' => :'authenticator',
70
+ :'groups' => :'groups',
71
+ :'email' => :'email',
72
+ :'password' => :'password'
73
+ }
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.swagger_types
78
+ {
79
+ :'name' => :'String',
80
+ :'description' => :'String',
81
+ :'authenticator' => :'String',
82
+ :'groups' => :'Array<String>',
83
+ :'email' => :'String',
84
+ :'password' => :'String'
85
+ }
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ return unless attributes.is_a?(Hash)
92
+
93
+ # convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
95
+
96
+ if attributes.has_key?(:'name')
97
+ self.name = attributes[:'name']
98
+ end
99
+
100
+ if attributes.has_key?(:'description')
101
+ self.description = attributes[:'description']
102
+ end
103
+
104
+ if attributes.has_key?(:'authenticator')
105
+ self.authenticator = attributes[:'authenticator']
106
+ end
107
+
108
+ if attributes.has_key?(:'groups')
109
+ if (value = attributes[:'groups']).is_a?(Array)
110
+ self.groups = value
111
+ end
112
+ end
113
+
114
+ if attributes.has_key?(:'email')
115
+ self.email = attributes[:'email']
116
+ end
117
+
118
+ if attributes.has_key?(:'password')
119
+ self.password = attributes[:'password']
120
+ end
121
+
122
+ end
123
+
124
+ # Show invalid properties with the reasons. Usually used together with valid?
125
+ # @return Array for valid properies with the reasons
126
+ def list_invalid_properties
127
+ invalid_properties = Array.new
128
+ return invalid_properties
129
+ end
130
+
131
+ # Check to see if the all the properties in the model are valid
132
+ # @return true if the model is valid
133
+ def valid?
134
+ authenticator_validator = EnumAttributeValidator.new('String', ["local", "ldap"])
135
+ return false unless authenticator_validator.valid?(@authenticator)
136
+ return true
137
+ end
138
+
139
+ # Custom attribute writer method checking allowed values (enum).
140
+ # @param [Object] authenticator Object to be assigned
141
+ def authenticator=(authenticator)
142
+ validator = EnumAttributeValidator.new('String', ["local", "ldap"])
143
+ unless validator.valid?(authenticator)
144
+ fail ArgumentError, "invalid value for 'authenticator', must be one of #{validator.allowable_values}."
145
+ end
146
+ @authenticator = authenticator
147
+ end
148
+
149
+ # Checks equality by comparing each attribute.
150
+ # @param [Object] Object to be compared
151
+ def ==(o)
152
+ return true if self.equal?(o)
153
+ self.class == o.class &&
154
+ name == o.name &&
155
+ description == o.description &&
156
+ authenticator == o.authenticator &&
157
+ groups == o.groups &&
158
+ email == o.email &&
159
+ password == o.password
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Fixnum] Hash code
170
+ def hash
171
+ [name, description, authenticator, groups, email, password].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ self.class.swagger_types.each_pair do |key, type|
180
+ if type =~ /^Array<(.*)>/i
181
+ # check to ensure the input is an array given that the the attribute
182
+ # is documented as an array but the input is not
183
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
184
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
185
+ end
186
+ elsif !attributes[self.class.attribute_map[key]].nil?
187
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
188
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
189
+ end
190
+
191
+ self
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def _deserialize(type, value)
199
+ case type.to_sym
200
+ when :DateTime
201
+ DateTime.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :BOOLEAN
211
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ temp_model = TriglavClient.const_get(type).new
232
+ temp_model.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ next if value.nil?
255
+ hash[param] = _to_hash(value)
256
+ end
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map{ |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to? :to_hash
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end
@@ -0,0 +1,300 @@
1
+ =begin
2
+ #Triglav API
3
+
4
+ #Triglav API
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: triglav_admin_my@dena.jp
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module TriglavClient
27
+
28
+ class UserResponse
29
+ attr_accessor :id
30
+
31
+ attr_accessor :name
32
+
33
+ attr_accessor :description
34
+
35
+ # local or ldap
36
+ attr_accessor :authenticator
37
+
38
+ attr_accessor :groups
39
+
40
+ attr_accessor :email
41
+
42
+ attr_accessor :created_at
43
+
44
+ attr_accessor :updated_at
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'id' => :'id',
72
+ :'name' => :'name',
73
+ :'description' => :'description',
74
+ :'authenticator' => :'authenticator',
75
+ :'groups' => :'groups',
76
+ :'email' => :'email',
77
+ :'created_at' => :'created_at',
78
+ :'updated_at' => :'updated_at'
79
+ }
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.swagger_types
84
+ {
85
+ :'id' => :'Integer',
86
+ :'name' => :'String',
87
+ :'description' => :'String',
88
+ :'authenticator' => :'String',
89
+ :'groups' => :'Array<String>',
90
+ :'email' => :'String',
91
+ :'created_at' => :'DateTime',
92
+ :'updated_at' => :'DateTime'
93
+ }
94
+ end
95
+
96
+ # Initializes the object
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ def initialize(attributes = {})
99
+ return unless attributes.is_a?(Hash)
100
+
101
+ # convert string to symbol for hash key
102
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
103
+
104
+ if attributes.has_key?(:'id')
105
+ self.id = attributes[:'id']
106
+ end
107
+
108
+ if attributes.has_key?(:'name')
109
+ self.name = attributes[:'name']
110
+ end
111
+
112
+ if attributes.has_key?(:'description')
113
+ self.description = attributes[:'description']
114
+ end
115
+
116
+ if attributes.has_key?(:'authenticator')
117
+ self.authenticator = attributes[:'authenticator']
118
+ end
119
+
120
+ if attributes.has_key?(:'groups')
121
+ if (value = attributes[:'groups']).is_a?(Array)
122
+ self.groups = value
123
+ end
124
+ end
125
+
126
+ if attributes.has_key?(:'email')
127
+ self.email = attributes[:'email']
128
+ end
129
+
130
+ if attributes.has_key?(:'created_at')
131
+ self.created_at = attributes[:'created_at']
132
+ end
133
+
134
+ if attributes.has_key?(:'updated_at')
135
+ self.updated_at = attributes[:'updated_at']
136
+ end
137
+
138
+ end
139
+
140
+ # Show invalid properties with the reasons. Usually used together with valid?
141
+ # @return Array for valid properies with the reasons
142
+ def list_invalid_properties
143
+ invalid_properties = Array.new
144
+ return invalid_properties
145
+ end
146
+
147
+ # Check to see if the all the properties in the model are valid
148
+ # @return true if the model is valid
149
+ def valid?
150
+ return false if @id.nil?
151
+ return false if @name.nil?
152
+ authenticator_validator = EnumAttributeValidator.new('String', ["local", "ldap"])
153
+ return false unless authenticator_validator.valid?(@authenticator)
154
+ return true
155
+ end
156
+
157
+ # Custom attribute writer method checking allowed values (enum).
158
+ # @param [Object] authenticator Object to be assigned
159
+ def authenticator=(authenticator)
160
+ validator = EnumAttributeValidator.new('String', ["local", "ldap"])
161
+ unless validator.valid?(authenticator)
162
+ fail ArgumentError, "invalid value for 'authenticator', must be one of #{validator.allowable_values}."
163
+ end
164
+ @authenticator = authenticator
165
+ end
166
+
167
+ # Checks equality by comparing each attribute.
168
+ # @param [Object] Object to be compared
169
+ def ==(o)
170
+ return true if self.equal?(o)
171
+ self.class == o.class &&
172
+ id == o.id &&
173
+ name == o.name &&
174
+ description == o.description &&
175
+ authenticator == o.authenticator &&
176
+ groups == o.groups &&
177
+ email == o.email &&
178
+ created_at == o.created_at &&
179
+ updated_at == o.updated_at
180
+ end
181
+
182
+ # @see the `==` method
183
+ # @param [Object] Object to be compared
184
+ def eql?(o)
185
+ self == o
186
+ end
187
+
188
+ # Calculates hash code according to all attributes.
189
+ # @return [Fixnum] Hash code
190
+ def hash
191
+ [id, name, description, authenticator, groups, email, created_at, updated_at].hash
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def build_from_hash(attributes)
198
+ return nil unless attributes.is_a?(Hash)
199
+ self.class.swagger_types.each_pair do |key, type|
200
+ if type =~ /^Array<(.*)>/i
201
+ # check to ensure the input is an array given that the the attribute
202
+ # is documented as an array but the input is not
203
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
204
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
205
+ end
206
+ elsif !attributes[self.class.attribute_map[key]].nil?
207
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
208
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
209
+ end
210
+
211
+ self
212
+ end
213
+
214
+ # Deserializes the data based on type
215
+ # @param string type Data type
216
+ # @param string value Value to be deserialized
217
+ # @return [Object] Deserialized data
218
+ def _deserialize(type, value)
219
+ case type.to_sym
220
+ when :DateTime
221
+ DateTime.parse(value)
222
+ when :Date
223
+ Date.parse(value)
224
+ when :String
225
+ value.to_s
226
+ when :Integer
227
+ value.to_i
228
+ when :Float
229
+ value.to_f
230
+ when :BOOLEAN
231
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
232
+ true
233
+ else
234
+ false
235
+ end
236
+ when :Object
237
+ # generic object (usually a Hash), return directly
238
+ value
239
+ when /\AArray<(?<inner_type>.+)>\z/
240
+ inner_type = Regexp.last_match[:inner_type]
241
+ value.map { |v| _deserialize(inner_type, v) }
242
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
243
+ k_type = Regexp.last_match[:k_type]
244
+ v_type = Regexp.last_match[:v_type]
245
+ {}.tap do |hash|
246
+ value.each do |k, v|
247
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
248
+ end
249
+ end
250
+ else # model
251
+ temp_model = TriglavClient.const_get(type).new
252
+ temp_model.build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ next if value.nil?
275
+ hash[param] = _to_hash(value)
276
+ end
277
+ hash
278
+ end
279
+
280
+ # Outputs non-array value in the form of hash
281
+ # For object, use to_hash. Otherwise, just return the value
282
+ # @param [Object] value Any valid value
283
+ # @return [Hash] Returns the value in the form of hash
284
+ def _to_hash(value)
285
+ if value.is_a?(Array)
286
+ value.compact.map{ |v| _to_hash(v) }
287
+ elsif value.is_a?(Hash)
288
+ {}.tap do |hash|
289
+ value.each { |k, v| hash[k] = _to_hash(v) }
290
+ end
291
+ elsif value.respond_to? :to_hash
292
+ value.to_hash
293
+ else
294
+ value
295
+ end
296
+ end
297
+
298
+ end
299
+
300
+ end