Module: Resque::Scheduler::Plugin
- Defined in:
- lib/resque/scheduler/plugin.rb
Class Method Summary collapse
- .hooks(job, pattern) ⇒ Object
- .process_schedule_hooks(klass, *args) ⇒ Object
- .run_after_schedule_hooks(klass, *args) ⇒ Object
- .run_before_delayed_enqueue_hooks(klass, *args) ⇒ Object
- .run_before_schedule_hooks(klass, *args) ⇒ Object
- .run_hooks(job, pattern, *args) ⇒ Object
Class Method Details
.hooks(job, pattern) ⇒ Object
15 16 17 |
# File 'lib/resque/scheduler/plugin.rb', line 15 def self.hooks(job, pattern) job.methods.grep(/^#{pattern}/).sort end |
.process_schedule_hooks(klass, *args) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/resque/scheduler/plugin.rb', line 6 def self.process_schedule_hooks(klass, *args) # the documentation states that if any before_schedule hook returns # false, the process should not be enqueued return unless run_before_schedule_hooks(klass, *args) yield run_after_schedule_hooks(klass, *args) end |
.run_after_schedule_hooks(klass, *args) ⇒ Object
35 36 37 |
# File 'lib/resque/scheduler/plugin.rb', line 35 def self.run_after_schedule_hooks(klass, *args) run_hooks(klass, 'after_schedule', *args) end |
.run_before_delayed_enqueue_hooks(klass, *args) ⇒ Object
27 28 29 |
# File 'lib/resque/scheduler/plugin.rb', line 27 def self.run_before_delayed_enqueue_hooks(klass, *args) run_hooks(klass, 'before_delayed_enqueue', *args) end |
.run_before_schedule_hooks(klass, *args) ⇒ Object
31 32 33 |
# File 'lib/resque/scheduler/plugin.rb', line 31 def self.run_before_schedule_hooks(klass, *args) run_hooks(klass, 'before_schedule', *args) end |
.run_hooks(job, pattern, *args) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/resque/scheduler/plugin.rb', line 19 def self.run_hooks(job, pattern, *args) results = hooks(job, pattern).map do |hook| job.send(hook, *args) end results.all? { |result| result != false } end |