Sha256: 5df072e1e28288413c5b19fab81ca1ec668b878367053f3daf31c4056fc4a14f

Contents?: true

Size: 652 Bytes

Versions: 10

Compression:

Stored size: 652 Bytes

Contents

require 'sucker_punch'

module DelayedCron
  module Jobs
    class SuckerPunch
      include ::SuckerPunch::Job

      def self.enqueue_delayed_cron(klass, method_name, options)
        unless scheduled?(klass)
          options.symbolize_keys!
          self.new.later(options[:interval], klass, method_name, options)
        end
      end

      def self.scheduled?(klass)
        ::SuckerPunch::Queue.new(klass).registered?
      end

      def perform(klass, method_name, options)
        DelayedCron.process_job(klass, method_name, options)
      end

      def later(sec, *args)
        after(sec) { perform(*args) }
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
delayed_cron-0.2.11 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.10 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.9 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.8 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.7 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.6 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.5 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.4 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.3 lib/delayed_cron/jobs/sucker_punch.rb
delayed_cron-0.2.2 lib/delayed_cron/jobs/sucker_punch.rb