Class: Bellbro::Worker
- Inherits:
-
Object
- Object
- Bellbro::Worker
- Extended by:
- SidekiqUtils
- Defined in:
- lib/bellbro/worker.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Attributes included from Trackable
Class Method Summary collapse
Instance Method Summary collapse
Methods included from SidekiqUtils
jobs, jobs_in_flight_with, jobs_with, number_of_active_workers, workers, workers_for_queue, workers_with
Methods included from Hooks
#abort!, #aborted?, included, #timed_out?, #timer
Methods included from Trackable
included, #record_add, #record_incr, #record_set, #record_update, #status_update, #stop_tracking, #track, #tracking?, #write_log
Methods included from Ringable
#error, included, logger, #ring
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/bellbro/worker.rb', line 9 def context @context end |
Class Method Details
.should_run? ⇒ Boolean
37 38 39 40 |
# File 'lib/bellbro/worker.rb', line 37 def self.should_run? # override true end |
Instance Method Details
#call ⇒ Object
25 26 27 |
# File 'lib/bellbro/worker.rb', line 25 def call # override end |
#debug? ⇒ Boolean
33 34 35 |
# File 'lib/bellbro/worker.rb', line 33 def debug? @debug ||= !!context[:debug] rescue false end |
#perform(args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bellbro/worker.rb', line 13 def perform(args) return unless args.present? set_context(args) run_before_hooks return if aborted? call return if aborted? run_after_hooks ensure run_always_hooks end |
#should_run? ⇒ Boolean
29 30 31 |
# File 'lib/bellbro/worker.rb', line 29 def should_run? self.class.should_run? || abort! end |