Sha256: 938128a7ef1fb5e18835bdef8eeba058ff563669c7d75752f29a4076df925b72

Contents?: true

Size: 752 Bytes

Versions: 20

Compression:

Stored size: 752 Bytes

Contents

# vim:fileencoding=utf-8

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

      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

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

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

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

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
resque-scheduler-4.10.2 lib/resque/scheduler/plugin.rb
resque-scheduler-4.10.1 lib/resque/scheduler/plugin.rb
resque-scheduler-4.10.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.9.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.8.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.7.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.6.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.5.0 lib/resque/scheduler/plugin.rb
istox-resque-scheduler-1.0.0.pre lib/resque/scheduler/plugin.rb
resque-scheduler-4.4.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.3.1 lib/resque/scheduler/plugin.rb
resque_admin-scheduler-1.0.2 lib/resque/scheduler/plugin.rb
resque-admin-scheduler-1.0.2 lib/resque/scheduler/plugin.rb
resque-scheduler-4.3.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.2.1 lib/resque/scheduler/plugin.rb
resque-scheduler-4.2.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.1.0 lib/resque/scheduler/plugin.rb
resque-scheduler-4.0.0 lib/resque/scheduler/plugin.rb
resque-scheduler-3.1.0 lib/resque/scheduler/plugin.rb
resque-scheduler-3.0.0 lib/resque/scheduler/plugin.rb