factor 0.5.10 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/factor/version.rb +1 -1
- data/lib/runtime.rb +39 -11
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/factor/version.rb
CHANGED
data/lib/runtime.rb
CHANGED
@@ -143,6 +143,43 @@ module Factor
|
|
143
143
|
|
144
144
|
private
|
145
145
|
|
146
|
+
class DeepStruct < OpenStruct
|
147
|
+
def initialize(hash=nil)
|
148
|
+
@table = {}
|
149
|
+
@hash_table = {}
|
150
|
+
|
151
|
+
if hash
|
152
|
+
hash.each do |k,v|
|
153
|
+
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
|
154
|
+
@hash_table[k.to_sym] = v
|
155
|
+
|
156
|
+
new_ostruct_member(k)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def to_h
|
162
|
+
@hash_table
|
163
|
+
end
|
164
|
+
|
165
|
+
def [](idx)
|
166
|
+
hash = marshal_dump
|
167
|
+
hash[idx.to_sym]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def simple_object_convert(item)
|
172
|
+
if item.is_a?(Hash)
|
173
|
+
DeepStruct.new(item)
|
174
|
+
elsif item.is_a?(Array)
|
175
|
+
item.map do |i|
|
176
|
+
simple_object_convert(i)
|
177
|
+
end
|
178
|
+
else
|
179
|
+
item
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
146
183
|
def flat_hash(h,f=[],g={})
|
147
184
|
return g.update({ f=>h }) unless h.is_a? Hash
|
148
185
|
h.each { |k,r| flat_hash(r,f+[k],g) }
|
@@ -161,17 +198,8 @@ module Factor
|
|
161
198
|
end
|
162
199
|
|
163
200
|
def error_handle_call(listener_response, &block)
|
164
|
-
|
165
|
-
|
166
|
-
elsif listener_response['payload'].is_a?(Array)
|
167
|
-
listener_response['payload'].map do |i|
|
168
|
-
i.is_a?(Hash) ? OpenStruct.new(i) : i
|
169
|
-
end
|
170
|
-
else
|
171
|
-
listener_response['payload']
|
172
|
-
end
|
173
|
-
block.call(payload) if block
|
174
|
-
|
201
|
+
content = simple_object_convert(listener_response['payload'])
|
202
|
+
block.call(content) if block
|
175
203
|
rescue => ex
|
176
204
|
error "Error in workflow definition: #{ex.message}"
|
177
205
|
ex.backtrace.each do |line|
|