Sha256: afe437c45a26a486eac95d482069e2d039feaf31fbd5f65341376f3cd8606cfc

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

require 'delayed_job_mongoid'

module Delayed
  module Backend
    module Base
      module ClassMethods
        # Add a job to the queue
        def enqueue(*args)
          object = args.shift
          unless object.respond_to?(:perform)
            raise ArgumentError, 'Cannot enqueue items which do not respond to perform'
          end

          attributes = {
            :job_type => object.class.name.demodulize.underscore,
            :payload_object => object,
            :priority => Delayed::Worker.default_priority,
            :run_at => nil
          }

          if args.first.respond_to?(:[])
            attributes.merge!(args.first)
          else
            attributes.merge!({
              :priority => args.first || Delayed::Worker.default_priority,
              :run_at   => args[1]
            })
          end

          self.create(attributes)
        end
      end

      def failed?
        failed_at.present?
      end
    end

    module Mongoid
      class Job
        field :job_type
        field :step
        referenced_in :site
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotive_cms-1.0.0.beta.2 lib/locomotive/delayed_job.rb
locomotive_cms-1.0.0.beta lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta12 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta11 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta10 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta9 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta8 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta7 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta5 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta4 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta3 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta2 lib/locomotive/delayed_job.rb
locomotive_cms-0.0.4.beta1 lib/locomotive/delayed_job.rb