Class: Async::Job
- Inherits:
-
Object
show all
- Defined in:
- lib/async.rb
Class Method Summary
collapse
Class Method Details
73
74
75
76
77
78
79
80
81
|
# File 'lib/async.rb', line 73
def self.perform(wrapper, receiver_class_str, receiver_id, method, args)
receiver_class = constantize(receiver_class_str)
receiver = receiver_id ? receiver_class.find(receiver_id) : receiver_class
untransform_args = untransform_args(args)
constantize(wrapper).run_now(receiver, method, untransform_args)
rescue => e
ErrorReporting.notify_exception(e,
receiver_class_str: receiver_class_str, receiver_id: receiver_id, method: method, args: args)
end
|
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/async.rb', line 83
def self.transform_args(args)
args.map do |x|
if x.class.respond_to?(:find)
{'_transform_arg' => true, 'class' => x.class.to_s, 'id' => x.id}
elsif x.is_a?(Array)
transform_args(x)
else
x
end
end
end
|
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/async.rb', line 95
def self.untransform_args(args)
args.map do |x|
if x.is_a?(Hash) && x['_transform_arg']
constantize(x['class']).find(x['id'])
elsif x.is_a?(Array)
untransform_args(x)
else
x
end
end
end
|