Sha256: 13a77c8a89811f47ac791d5f1d5cd2af3b21e384bba1e1602ff4c8ff71102079

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

unless defined? $__rq_job__
  module RQ 
#--{{{
    LIBDIR = File::dirname(File::expand_path(__FILE__)) + File::SEPARATOR unless
      defined? LIBDIR

    require 'arrayfields'
    require 'yaml'

    require LIBDIR + 'util'
    require LIBDIR + 'qdb'

    #
    # Job is a convenience class which stamps out a QDB::tuple and extends it
    # with methods that give accessor methods for each field in the hash 
    #
    class Job < Array
#--{{{
      include ArrayFields
      def initialize kvs = {}
#--{{{
        self.fields = QDB::FIELDS
        (kvs.keys - self.fields).each{|k| self[k] = kvs[k]}
#--}}}
      end
      def method_missing(meth, *args, &block)
#--{{{
        setpat = %r/=$/o
        meth = "#{ meth }"
        setter = meth =~ setpat 
        meth.gsub! setpat, ''
        if fields.include? "#{ meth }"
          if setter
            self.send('[]=', meth, *args, &block)
          else
            self.send('[]', meth, *args, &block)
          end
        else
          super
        end
#--}}}
      end
      def to_yaml
        to_hash.to_yaml
      end
#--}}}
    end # class Job
#--}}}
  end # module RQ
$__rq_job__ = __FILE__ 
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rq-3.5.3 lib/rq/job.rb
rq-3.5.1 lib/rq/job.rb
rq-3.5.0 lib/rq/job.rb
rq-ruby1.8-3.4.7 lib/rq/job.rb
rq-ruby1.8-3.4.6 lib/rq/job.rb
rq-ruby1.8-3.4.5 lib/rq/job.rb
rq-ruby1.8-3.4.3 lib/rq/job.rb
rq-3.0.0 lib/rq-3.0.0/job.rb
rq-3.1.0 lib/rq-3.1.0/job.rb
rq-3.3.0 lib/rq/job.rb
rq-3.4.0 lib/rq/job.rb