Module: Rapid::Job

Defined in:
lib/rapid/job.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/rapid/job.rb', line 3

def self.included(base)
  base.send(:extend, ClassMethods)
end

Instance Method Details

#rapid(attr = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rapid/job.rb', line 25

def rapid attr={}
  job = Rapid::Task.new self.class.to_s, self.to_json, attr
  methods = self.public_methods - self.class.superclass.instance_methods
  methods.each do |method_name|
    job.metaclass.send(:define_method, method_name) do |*args|
      self.method_name= method_name
      self.args= args
      self.enqueue
      self
    end
  end
  job
end