Module: ResqueAdmin::Scheduler::Plugin

Defined in:
lib/resque_admin/scheduler/plugin.rb

Class Method Summary collapse

Class Method Details

.hooks(job, pattern) ⇒ Object



6
7
8
# File 'lib/resque_admin/scheduler/plugin.rb', line 6

def self.hooks(job, pattern)
  job.methods.grep(/^#{pattern}/).sort
end

.run_after_schedule_hooks(klass, *args) ⇒ Object



26
27
28
# File 'lib/resque_admin/scheduler/plugin.rb', line 26

def self.run_after_schedule_hooks(klass, *args)
  run_hooks(klass, 'after_schedule', *args)
end

.run_before_delayed_enqueue_hooks(klass, *args) ⇒ Object



18
19
20
# File 'lib/resque_admin/scheduler/plugin.rb', line 18

def self.run_before_delayed_enqueue_hooks(klass, *args)
  run_hooks(klass, 'before_delayed_enqueue', *args)
end

.run_before_schedule_hooks(klass, *args) ⇒ Object



22
23
24
# File 'lib/resque_admin/scheduler/plugin.rb', line 22

def self.run_before_schedule_hooks(klass, *args)
  run_hooks(klass, 'before_schedule', *args)
end

.run_hooks(job, pattern, *args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/resque_admin/scheduler/plugin.rb', line 10

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