Class: Marty::PromiseRubyJob
- Inherits:
-
Struct
- Object
- Struct
- Marty::PromiseRubyJob
- Defined in:
- lib/marty/promise_ruby_job.rb
Instance Attribute Summary collapse
-
#hook ⇒ Object
Returns the value of attribute hook.
-
#method_args ⇒ Object
Returns the value of attribute method_args.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#module_name ⇒ Object
Returns the value of attribute module_name.
-
#promise ⇒ Object
Returns the value of attribute promise.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
Instance Attribute Details
#hook ⇒ Object
Returns the value of attribute hook
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def hook @hook end |
#method_args ⇒ Object
Returns the value of attribute method_args
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def method_args @method_args end |
#method_name ⇒ Object
Returns the value of attribute method_name
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def method_name @method_name end |
#module_name ⇒ Object
Returns the value of attribute module_name
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def module_name @module_name end |
#promise ⇒ Object
Returns the value of attribute promise
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def promise @promise end |
#title ⇒ Object
Returns the value of attribute title
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def title @title end |
Instance Method Details
#enqueue(job) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/marty/promise_ruby_job.rb', line 9 def enqueue(job) config = Rails.configuration.marty hooks = config.promise_job_enqueue_hooks return if hooks.blank? hooks.each do |hook| hook.call(job) end end |
#max_attempts ⇒ Object
44 45 46 |
# File 'lib/marty/promise_ruby_job.rb', line 44 def max_attempts 1 end |
#perform ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/marty/promise_ruby_job.rb', line 20 def perform promise.set_start begin Mcfly.whodunnit = promise.user mod = module_name.constantize res = { 'result' => mod.send(method_name, *method_args) } rescue StandardError => e res = ::Marty::Promise.exception_to_result(promise: promise, exception: e) end promise.set_result(res) process_hook(res) end |