Module: RabbitJobs::Job::ClassMethods
- Defined in:
- lib/rabbit_jobs/job.rb
Overview
DSL method for jobs
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 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
112 113 114 115 116 117 118 119 120 |
# File 'lib/rabbit_jobs/job.rb', line 112 def on_error(*hooks) @rj_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 @rj_on_error_hooks << proc_or_symbol end end |
#perform(*params) ⇒ Object
131 132 133 |
# File 'lib/rabbit_jobs/job.rb', line 131 def perform(*params) new.perform(*params) end |
#perform_async(*args) ⇒ Object
127 128 129 |
# File 'lib/rabbit_jobs/job.rb', line 127 def perform_async(*args) RJ::Publisher.publish_to(@rj_queue, self, *args) end |
#queue(routing_key) ⇒ Object
122 123 124 125 |
# File 'lib/rabbit_jobs/job.rb', line 122 def queue(routing_key) fail ArgumentError, 'routing_key is blank' if routing_key.blank? @rj_queue = routing_key.to_sym end |