iron_titan 0.0.1
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 +7 -0
- data/README.md +10 -0
- data/lib/iron_titan/api/core_api.rb +263 -0
- data/lib/iron_titan/api/jobs_api.rb +383 -0
- data/lib/iron_titan/api_client.rb +332 -0
- data/lib/iron_titan/api_error.rb +36 -0
- data/lib/iron_titan/configuration.rb +163 -0
- data/lib/iron_titan/models/error.rb +158 -0
- data/lib/iron_titan/models/error_body.rb +168 -0
- data/lib/iron_titan/models/job.rb +269 -0
- data/lib/iron_titan/models/job_array.rb +160 -0
- data/lib/iron_titan/models/job_wrapper.rb +158 -0
- data/lib/iron_titan/models/new_job.rb +214 -0
- data/lib/iron_titan/models/new_job_array.rb +160 -0
- data/lib/iron_titan/version.rb +15 -0
- data/lib/iron_titan.rb +48 -0
- data/spec/api/CoreApi_spec.rb +99 -0
- data/spec/api/JobsApi_spec.rb +131 -0
- data/spec/models/ErrorBody_spec.rb +56 -0
- data/spec/models/Error_spec.rb +46 -0
- data/spec/models/JobArray_spec.rb +46 -0
- data/spec/models/JobWrapper_spec.rb +46 -0
- data/spec/models/Job_spec.rb +146 -0
- data/spec/models/NewJobArray_spec.rb +46 -0
- data/spec/models/NewJob_spec.rb +96 -0
- metadata +257 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
=begin
|
2
|
+
Titan API
|
3
|
+
|
4
|
+
The ultimate, language agnostic, container based job processing framework.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module IronTitan
|
16
|
+
class ErrorBody
|
17
|
+
attr_accessor :message
|
18
|
+
|
19
|
+
attr_accessor :fields
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
|
25
|
+
:'message' => :'message',
|
26
|
+
|
27
|
+
:'fields' => :'fields'
|
28
|
+
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.swagger_types
|
34
|
+
{
|
35
|
+
:'message' => :'String',
|
36
|
+
:'fields' => :'String'
|
37
|
+
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
46
|
+
|
47
|
+
|
48
|
+
if attributes[:'message']
|
49
|
+
self.message = attributes[:'message']
|
50
|
+
end
|
51
|
+
|
52
|
+
if attributes[:'fields']
|
53
|
+
self.fields = attributes[:'fields']
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
# Check equality by comparing each attribute.
|
59
|
+
def ==(o)
|
60
|
+
return true if self.equal?(o)
|
61
|
+
self.class == o.class &&
|
62
|
+
message == o.message &&
|
63
|
+
fields == o.fields
|
64
|
+
end
|
65
|
+
|
66
|
+
# @see the `==` method
|
67
|
+
def eql?(o)
|
68
|
+
self == o
|
69
|
+
end
|
70
|
+
|
71
|
+
# Calculate hash code according to all attributes.
|
72
|
+
def hash
|
73
|
+
[message, fields].hash
|
74
|
+
end
|
75
|
+
|
76
|
+
# build the object from hash
|
77
|
+
def build_from_hash(attributes)
|
78
|
+
return nil unless attributes.is_a?(Hash)
|
79
|
+
self.class.swagger_types.each_pair do |key, type|
|
80
|
+
if type =~ /^Array<(.*)>/i
|
81
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
82
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
83
|
+
else
|
84
|
+
#TODO show warning in debug mode
|
85
|
+
end
|
86
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
87
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
88
|
+
else
|
89
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
def _deserialize(type, value)
|
97
|
+
case type.to_sym
|
98
|
+
when :DateTime
|
99
|
+
DateTime.parse(value)
|
100
|
+
when :Date
|
101
|
+
Date.parse(value)
|
102
|
+
when :String
|
103
|
+
value.to_s
|
104
|
+
when :Integer
|
105
|
+
value.to_i
|
106
|
+
when :Float
|
107
|
+
value.to_f
|
108
|
+
when :BOOLEAN
|
109
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
110
|
+
true
|
111
|
+
else
|
112
|
+
false
|
113
|
+
end
|
114
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
115
|
+
inner_type = Regexp.last_match[:inner_type]
|
116
|
+
value.map { |v| _deserialize(inner_type, v) }
|
117
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
118
|
+
k_type = Regexp.last_match[:k_type]
|
119
|
+
v_type = Regexp.last_match[:v_type]
|
120
|
+
{}.tap do |hash|
|
121
|
+
value.each do |k, v|
|
122
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
else # model
|
126
|
+
_model = IronTitan.const_get(type).new
|
127
|
+
_model.build_from_hash(value)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def to_s
|
132
|
+
to_hash.to_s
|
133
|
+
end
|
134
|
+
|
135
|
+
# to_body is an alias to to_body (backward compatibility))
|
136
|
+
def to_body
|
137
|
+
to_hash
|
138
|
+
end
|
139
|
+
|
140
|
+
# return the object in the form of hash
|
141
|
+
def to_hash
|
142
|
+
hash = {}
|
143
|
+
self.class.attribute_map.each_pair do |attr, param|
|
144
|
+
value = self.send(attr)
|
145
|
+
next if value.nil?
|
146
|
+
hash[param] = _to_hash(value)
|
147
|
+
end
|
148
|
+
hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Method to output non-array value in the form of hash
|
152
|
+
# For object, use to_hash. Otherwise, just return the value
|
153
|
+
def _to_hash(value)
|
154
|
+
if value.is_a?(Array)
|
155
|
+
value.compact.map{ |v| _to_hash(v) }
|
156
|
+
elsif value.is_a?(Hash)
|
157
|
+
{}.tap do |hash|
|
158
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
159
|
+
end
|
160
|
+
elsif value.respond_to? :to_hash
|
161
|
+
value.to_hash
|
162
|
+
else
|
163
|
+
value
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,269 @@
|
|
1
|
+
=begin
|
2
|
+
Titan API
|
3
|
+
|
4
|
+
The ultimate, language agnostic, container based job processing framework.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module IronTitan
|
16
|
+
class Job
|
17
|
+
# Docker image to use for job.
|
18
|
+
attr_accessor :image
|
19
|
+
|
20
|
+
# Number of retries. Default 3.
|
21
|
+
attr_accessor :retries
|
22
|
+
|
23
|
+
# Time when job completed, whether it was successul or failed.
|
24
|
+
attr_accessor :completed_at
|
25
|
+
|
26
|
+
# Number of seconds to wait before starting. Default 0.
|
27
|
+
attr_accessor :delay
|
28
|
+
|
29
|
+
# Payload for the job. This is what you pass into each job to make it do something.
|
30
|
+
attr_accessor :payload
|
31
|
+
|
32
|
+
# Docker image to use for job. Default is 'image'
|
33
|
+
attr_accessor :name
|
34
|
+
|
35
|
+
# Time when job was submitted.
|
36
|
+
attr_accessor :created_at
|
37
|
+
|
38
|
+
# Time when job started execution.
|
39
|
+
attr_accessor :started_at
|
40
|
+
|
41
|
+
# Unique identifier representing a specific job.
|
42
|
+
attr_accessor :id
|
43
|
+
|
44
|
+
# Maximum runtime in seconds. If job runs for longer, it will be killed. Default 60 seconds.
|
45
|
+
attr_accessor :timeout
|
46
|
+
|
47
|
+
# Status of job. One of: [pending, running, success, error, timeout]
|
48
|
+
attr_accessor :status
|
49
|
+
|
50
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
51
|
+
def self.attribute_map
|
52
|
+
{
|
53
|
+
|
54
|
+
:'image' => :'image',
|
55
|
+
|
56
|
+
:'retries' => :'retries',
|
57
|
+
|
58
|
+
:'completed_at' => :'completed_at',
|
59
|
+
|
60
|
+
:'delay' => :'delay',
|
61
|
+
|
62
|
+
:'payload' => :'payload',
|
63
|
+
|
64
|
+
:'name' => :'name',
|
65
|
+
|
66
|
+
:'created_at' => :'created_at',
|
67
|
+
|
68
|
+
:'started_at' => :'started_at',
|
69
|
+
|
70
|
+
:'id' => :'id',
|
71
|
+
|
72
|
+
:'timeout' => :'timeout',
|
73
|
+
|
74
|
+
:'status' => :'status'
|
75
|
+
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
# Attribute type mapping.
|
80
|
+
def self.swagger_types
|
81
|
+
{
|
82
|
+
:'image' => :'String',
|
83
|
+
:'retries' => :'Integer',
|
84
|
+
:'completed_at' => :'DateTime',
|
85
|
+
:'delay' => :'Float',
|
86
|
+
:'payload' => :'String',
|
87
|
+
:'name' => :'String',
|
88
|
+
:'created_at' => :'DateTime',
|
89
|
+
:'started_at' => :'DateTime',
|
90
|
+
:'id' => :'String',
|
91
|
+
:'timeout' => :'Float',
|
92
|
+
:'status' => :'String'
|
93
|
+
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
def initialize(attributes = {})
|
98
|
+
return unless attributes.is_a?(Hash)
|
99
|
+
|
100
|
+
# convert string to symbol for hash key
|
101
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
102
|
+
|
103
|
+
|
104
|
+
if attributes[:'image']
|
105
|
+
self.image = attributes[:'image']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes[:'retries']
|
109
|
+
self.retries = attributes[:'retries']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes[:'completed_at']
|
113
|
+
self.completed_at = attributes[:'completed_at']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes[:'delay']
|
117
|
+
self.delay = attributes[:'delay']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes[:'payload']
|
121
|
+
self.payload = attributes[:'payload']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes[:'name']
|
125
|
+
self.name = attributes[:'name']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes[:'created_at']
|
129
|
+
self.created_at = attributes[:'created_at']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes[:'started_at']
|
133
|
+
self.started_at = attributes[:'started_at']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes[:'id']
|
137
|
+
self.id = attributes[:'id']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes[:'timeout']
|
141
|
+
self.timeout = attributes[:'timeout']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes[:'status']
|
145
|
+
self.status = attributes[:'status']
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
# Check equality by comparing each attribute.
|
151
|
+
def ==(o)
|
152
|
+
return true if self.equal?(o)
|
153
|
+
self.class == o.class &&
|
154
|
+
image == o.image &&
|
155
|
+
retries == o.retries &&
|
156
|
+
completed_at == o.completed_at &&
|
157
|
+
delay == o.delay &&
|
158
|
+
payload == o.payload &&
|
159
|
+
name == o.name &&
|
160
|
+
created_at == o.created_at &&
|
161
|
+
started_at == o.started_at &&
|
162
|
+
id == o.id &&
|
163
|
+
timeout == o.timeout &&
|
164
|
+
status == o.status
|
165
|
+
end
|
166
|
+
|
167
|
+
# @see the `==` method
|
168
|
+
def eql?(o)
|
169
|
+
self == o
|
170
|
+
end
|
171
|
+
|
172
|
+
# Calculate hash code according to all attributes.
|
173
|
+
def hash
|
174
|
+
[image, retries, completed_at, delay, payload, name, created_at, started_at, id, timeout, status].hash
|
175
|
+
end
|
176
|
+
|
177
|
+
# build the object from hash
|
178
|
+
def build_from_hash(attributes)
|
179
|
+
return nil unless attributes.is_a?(Hash)
|
180
|
+
self.class.swagger_types.each_pair do |key, type|
|
181
|
+
if type =~ /^Array<(.*)>/i
|
182
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
183
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
184
|
+
else
|
185
|
+
#TODO show warning in debug mode
|
186
|
+
end
|
187
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
188
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
189
|
+
else
|
190
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
self
|
195
|
+
end
|
196
|
+
|
197
|
+
def _deserialize(type, value)
|
198
|
+
case type.to_sym
|
199
|
+
when :DateTime
|
200
|
+
DateTime.parse(value)
|
201
|
+
when :Date
|
202
|
+
Date.parse(value)
|
203
|
+
when :String
|
204
|
+
value.to_s
|
205
|
+
when :Integer
|
206
|
+
value.to_i
|
207
|
+
when :Float
|
208
|
+
value.to_f
|
209
|
+
when :BOOLEAN
|
210
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
211
|
+
true
|
212
|
+
else
|
213
|
+
false
|
214
|
+
end
|
215
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
216
|
+
inner_type = Regexp.last_match[:inner_type]
|
217
|
+
value.map { |v| _deserialize(inner_type, v) }
|
218
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
219
|
+
k_type = Regexp.last_match[:k_type]
|
220
|
+
v_type = Regexp.last_match[:v_type]
|
221
|
+
{}.tap do |hash|
|
222
|
+
value.each do |k, v|
|
223
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
else # model
|
227
|
+
_model = IronTitan.const_get(type).new
|
228
|
+
_model.build_from_hash(value)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def to_s
|
233
|
+
to_hash.to_s
|
234
|
+
end
|
235
|
+
|
236
|
+
# to_body is an alias to to_body (backward compatibility))
|
237
|
+
def to_body
|
238
|
+
to_hash
|
239
|
+
end
|
240
|
+
|
241
|
+
# return the object in the form of hash
|
242
|
+
def to_hash
|
243
|
+
hash = {}
|
244
|
+
self.class.attribute_map.each_pair do |attr, param|
|
245
|
+
value = self.send(attr)
|
246
|
+
next if value.nil?
|
247
|
+
hash[param] = _to_hash(value)
|
248
|
+
end
|
249
|
+
hash
|
250
|
+
end
|
251
|
+
|
252
|
+
# Method to output non-array value in the form of hash
|
253
|
+
# For object, use to_hash. Otherwise, just return the value
|
254
|
+
def _to_hash(value)
|
255
|
+
if value.is_a?(Array)
|
256
|
+
value.compact.map{ |v| _to_hash(v) }
|
257
|
+
elsif value.is_a?(Hash)
|
258
|
+
{}.tap do |hash|
|
259
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
260
|
+
end
|
261
|
+
elsif value.respond_to? :to_hash
|
262
|
+
value.to_hash
|
263
|
+
else
|
264
|
+
value
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
=begin
|
2
|
+
Titan API
|
3
|
+
|
4
|
+
The ultimate, language agnostic, container based job processing framework.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module IronTitan
|
16
|
+
class JobArray
|
17
|
+
attr_accessor :jobs
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
|
23
|
+
:'jobs' => :'jobs'
|
24
|
+
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'jobs' => :'Array<Job>'
|
32
|
+
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(attributes = {})
|
37
|
+
return unless attributes.is_a?(Hash)
|
38
|
+
|
39
|
+
# convert string to symbol for hash key
|
40
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
41
|
+
|
42
|
+
|
43
|
+
if attributes[:'jobs']
|
44
|
+
if (value = attributes[:'jobs']).is_a?(Array)
|
45
|
+
self.jobs = value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
# Check equality by comparing each attribute.
|
52
|
+
def ==(o)
|
53
|
+
return true if self.equal?(o)
|
54
|
+
self.class == o.class &&
|
55
|
+
jobs == o.jobs
|
56
|
+
end
|
57
|
+
|
58
|
+
# @see the `==` method
|
59
|
+
def eql?(o)
|
60
|
+
self == o
|
61
|
+
end
|
62
|
+
|
63
|
+
# Calculate hash code according to all attributes.
|
64
|
+
def hash
|
65
|
+
[jobs].hash
|
66
|
+
end
|
67
|
+
|
68
|
+
# build the object from hash
|
69
|
+
def build_from_hash(attributes)
|
70
|
+
return nil unless attributes.is_a?(Hash)
|
71
|
+
self.class.swagger_types.each_pair do |key, type|
|
72
|
+
if type =~ /^Array<(.*)>/i
|
73
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
74
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
75
|
+
else
|
76
|
+
#TODO show warning in debug mode
|
77
|
+
end
|
78
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
79
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
80
|
+
else
|
81
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
self
|
86
|
+
end
|
87
|
+
|
88
|
+
def _deserialize(type, value)
|
89
|
+
case type.to_sym
|
90
|
+
when :DateTime
|
91
|
+
DateTime.parse(value)
|
92
|
+
when :Date
|
93
|
+
Date.parse(value)
|
94
|
+
when :String
|
95
|
+
value.to_s
|
96
|
+
when :Integer
|
97
|
+
value.to_i
|
98
|
+
when :Float
|
99
|
+
value.to_f
|
100
|
+
when :BOOLEAN
|
101
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
102
|
+
true
|
103
|
+
else
|
104
|
+
false
|
105
|
+
end
|
106
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
107
|
+
inner_type = Regexp.last_match[:inner_type]
|
108
|
+
value.map { |v| _deserialize(inner_type, v) }
|
109
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
110
|
+
k_type = Regexp.last_match[:k_type]
|
111
|
+
v_type = Regexp.last_match[:v_type]
|
112
|
+
{}.tap do |hash|
|
113
|
+
value.each do |k, v|
|
114
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
else # model
|
118
|
+
_model = IronTitan.const_get(type).new
|
119
|
+
_model.build_from_hash(value)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def to_s
|
124
|
+
to_hash.to_s
|
125
|
+
end
|
126
|
+
|
127
|
+
# to_body is an alias to to_body (backward compatibility))
|
128
|
+
def to_body
|
129
|
+
to_hash
|
130
|
+
end
|
131
|
+
|
132
|
+
# return the object in the form of hash
|
133
|
+
def to_hash
|
134
|
+
hash = {}
|
135
|
+
self.class.attribute_map.each_pair do |attr, param|
|
136
|
+
value = self.send(attr)
|
137
|
+
next if value.nil?
|
138
|
+
hash[param] = _to_hash(value)
|
139
|
+
end
|
140
|
+
hash
|
141
|
+
end
|
142
|
+
|
143
|
+
# Method to output non-array value in the form of hash
|
144
|
+
# For object, use to_hash. Otherwise, just return the value
|
145
|
+
def _to_hash(value)
|
146
|
+
if value.is_a?(Array)
|
147
|
+
value.compact.map{ |v| _to_hash(v) }
|
148
|
+
elsif value.is_a?(Hash)
|
149
|
+
{}.tap do |hash|
|
150
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
151
|
+
end
|
152
|
+
elsif value.respond_to? :to_hash
|
153
|
+
value.to_hash
|
154
|
+
else
|
155
|
+
value
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
end
|