Sha256: e255d07cb1e8e2d05a26d27fe23d2733fd444fe93e6a613a1b62141f6efbc904

Contents?: true

Size: 941 Bytes

Versions: 6

Compression:

Stored size: 941 Bytes

Contents

module Bricks
  module Worker
    class Job < ActiveRecord::Base
      include RubyLess
      set_table_name :delayed_jobs

      safe_method  :run_at => Time, :created_at => Time, :info   => String
      # can be nil
      safe_context :locked_at => Time, :locked_by => String

      def info
        obj = YAML.load(self[:handler])
        if obj.respond_to?(:info)
          obj.info
        else
          obj.inspect
        end
      end
    end # Job

    module ViewMethods
      include RubyLess

      safe_context :delayed_jobs => [Job]

      def delayed_jobs
        jobs = Bricks::Worker::Job.find(:all,
          # FIXME: find a way to add site_id to delayed_jobs...
          #:conditions => ['site_id = ?', current_site.id],
          :order => 'run_at ASC'
        )
        jobs.empty? ? nil : jobs
      end
    end # ViewMethods
  end # Worker
end

# Make sure the class is loaded before first YAML.load
Zena::SiteWorker

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zena-1.1.3 bricks/worker/lib/bricks/worker.rb
zena-1.1.2 bricks/worker/lib/bricks/worker.rb
zena-1.1.1 bricks/worker/lib/bricks/worker.rb
zena-1.1.0 bricks/worker/lib/bricks/worker.rb
zena-1.0.0 bricks/worker/lib/bricks/worker.rb
zena-1.0.0.rc3 bricks/worker/lib/bricks/worker.rb