Sha256: 3efbf0442fcc149ded5c4bdc3f0b8bf22ddca78bc139816c919347a69b06ceb0

Contents?: true

Size: 665 Bytes

Versions: 7

Compression:

Stored size: 665 Bytes

Contents

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

    def run_hooks(job, pattern, *args)
      results = hooks(job, pattern).collect do |hook|
        job.send(hook, *args)
      end

      results.all? { |result| result != false }
    end

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
resque-scheduler-2.5.5 lib/resque_scheduler/plugin.rb
resque-scheduler-2.5.4 lib/resque_scheduler/plugin.rb
resque-scheduler-2.5.3 lib/resque_scheduler/plugin.rb
resque-scheduler-2.5.2 lib/resque_scheduler/plugin.rb
resque-scheduler-2.5.1 lib/resque_scheduler/plugin.rb
resque-scheduler-2.5.0 lib/resque_scheduler/plugin.rb
resque-scheduler-2.4.0 lib/resque_scheduler/plugin.rb