Module: RabbitJobs::Job::ClassMethods
- Defined in:
- lib/rabbit_jobs/job.rb
Overview
DSL method for jobs
Instance Attribute Summary collapse
-
#on_error_hooks ⇒ Object
readonly
Returns the value of attribute on_error_hooks.
Instance Method Summary collapse
- #expires_in(seconds = nil) ⇒ Object
- #on_error(*hooks) ⇒ Object
- #perform(*params) ⇒ Object
- #perform_async(*args) ⇒ Object
- #queue(routing_key) ⇒ Object
Instance Attribute Details
#on_error_hooks ⇒ Object (readonly)
Returns the value of attribute on_error_hooks.
112 113 114 |
# File 'lib/rabbit_jobs/job.rb', line 112 def on_error_hooks @on_error_hooks end |
Instance Method Details
#expires_in(seconds = nil) ⇒ Object
107 108 109 110 |
# File 'lib/rabbit_jobs/job.rb', line 107 def expires_in(seconds = nil) @expires_in = seconds.to_i if seconds @expires_in end |
#on_error(*hooks) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/rabbit_jobs/job.rb', line 114 def on_error(*hooks) @on_error_hooks ||= [] hooks.each do |proc_or_symbol| unless proc_or_symbol.is_a?(Proc) || proc_or_symbol.is_a?(Symbol) fail ArgumentError.new, 'Pass proc or symbol to on_error hook' end @on_error_hooks << proc_or_symbol end end |
#perform(*params) ⇒ Object
133 134 135 |
# File 'lib/rabbit_jobs/job.rb', line 133 def perform(*params) new.perform(*params) end |
#perform_async(*args) ⇒ Object
129 130 131 |
# File 'lib/rabbit_jobs/job.rb', line 129 def perform_async(*args) RJ::Publisher.publish_to(@rj_queue, self, *args) end |
#queue(routing_key) ⇒ Object
124 125 126 127 |
# File 'lib/rabbit_jobs/job.rb', line 124 def queue(routing_key) fail ArgumentError, 'routing_key is blank' if routing_key.blank? @rj_queue = routing_key.to_sym end |