Class: DelayedMethod

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Inflector
Defined in:
lib/delayed-method.rb

Class Method Summary collapse

Class Method Details

.enqueue(object, method, *args) ⇒ Object



18
19
20
21
22
# File 'lib/delayed-method.rb', line 18

def enqueue(object, method, *args)
  ensure_proper_call(object, method) do |klass, id|
    Resque.enqueue(DelayedMethod, klass, id, method, *args)
  end
end

.enqueue_at(time, object, method, *args) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/delayed-method.rb', line 24

def enqueue_at(time, object, method, *args)
  ensure_proper_call(object, method) do |klass, id|
    if Resque.respond_to?(:enqueue_at)
      Resque.enqueue_at(time, DelayedMethod, klass, id, method, *args)
    else
      raise "resque-scheduler need to be included for this to work"
    end
  end
end

.perform(klass_name, instance_id, method, *args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/delayed-method.rb', line 10

def perform(klass_name, instance_id, method, *args)
  if instance_id
    constantize(klass_name).find(instance_id).send(method, *args)
  else
    constantize(klass_name).send(method, *args)
  end
end