Class: ResqueExtensions::AsyncMethod
- Inherits:
-
Object
- Object
- ResqueExtensions::AsyncMethod
- Defined in:
- lib/resque_extensions/async_method.rb
Constant Summary collapse
- OPTIONAL_SETTINGS =
[:queue]
- ACTIVERECORD_PREFIX =
"_ActiveRecord::"- CLASS_PREFIX =
"_Class::"
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
Instance Method Summary collapse
-
#class_method? ⇒ Boolean
Is the caller a class or an instance of a class.
-
#enqueue! ⇒ Object
enqueue the job so that it can be performed.
-
#initialize(caller, method, *args) ⇒ AsyncMethod
constructor
Constructor.
-
#instance_method? ⇒ Boolean
Is the caller an instance or a class.
-
#queue ⇒ Object
the queue for this job.
Constructor Details
#initialize(caller, method, *args) ⇒ AsyncMethod
Constructor
23 24 25 26 27 28 29 30 |
# File 'lib/resque_extensions/async_method.rb', line 23 def initialize(caller, method, *args) @caller = caller @method = method # set up our options self.(args) # leftover args are assigned @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/resque_extensions/async_method.rb', line 10 def args @args end |
Class Method Details
.perform(*args) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/resque_extensions/async_method.rb', line 12 def self.perform(*args) data = self.reify_data(args) caller = data.shift # call the method with all the args caller.send(*data) end |
Instance Method Details
#class_method? ⇒ Boolean
Is the caller a class or an instance of a class
34 35 36 |
# File 'lib/resque_extensions/async_method.rb', line 34 def class_method? @caller.is_a?(Class) end |
#enqueue! ⇒ Object
enqueue the job so that it can be performed
40 41 42 43 44 |
# File 'lib/resque_extensions/async_method.rb', line 40 def enqueue! Resque::Job.create( self.queue, self.class, *self.data_to_enqueue ) end |
#instance_method? ⇒ Boolean
Is the caller an instance or a class
47 48 49 |
# File 'lib/resque_extensions/async_method.rb', line 47 def instance_method? !self.class_method? end |
#queue ⇒ Object
the queue for this job
52 53 54 |
# File 'lib/resque_extensions/async_method.rb', line 52 def queue @queue ||= "default" end |