Sha256: 41ee672c15e743ed64110d7cabfaf920586ace8d71b6678f93ffae448772ef0e

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

module Bricks
  module Worker
    # This is only used to display jobs. Job creation is done in Delayed::Job.
    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 = current_site.jobs
        jobs.empty? ? nil : jobs
      end
    end # ViewMethods
    
    module SiteMethods
      def jobs
        Bricks::Worker::Job.all(
          :conditions => ['site_id = ?', self.id],
          :order => 'run_at ASC'
        )
      end
    end
  end # Worker
end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zena-1.2.7 bricks/worker/lib/bricks/worker.rb
zena-1.2.6 bricks/worker/lib/bricks/worker.rb
zena-1.2.5 bricks/worker/lib/bricks/worker.rb
zena-1.2.4 bricks/worker/lib/bricks/worker.rb
zena-1.2.3 bricks/worker/lib/bricks/worker.rb
zena-1.2.2 bricks/worker/lib/bricks/worker.rb
zena-1.2.1 bricks/worker/lib/bricks/worker.rb
zena-1.2.0 bricks/worker/lib/bricks/worker.rb