Class: ActiveQueue::Job
- Inherits:
-
Object
- Object
- ActiveQueue::Job
- Extended by:
- ClassMethods
- Defined in:
- lib/active_queue/job.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#job_klass ⇒ Object
Returns the value of attribute job_klass.
-
#options ⇒ Object
Returns the value of attribute options.
-
#perform_action ⇒ Object
Returns the value of attribute perform_action.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#queue_adapter ⇒ Object
Returns the value of attribute queue_adapter.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
-
#val ⇒ Object
Returns the value of attribute val.
Instance Method Summary collapse
- #adapters ⇒ Object
- #enqueue ⇒ Object
-
#initialize(options) ⇒ Job
constructor
A new instance of Job.
- #perform(opt = nil) ⇒ Object
Constructor Details
#initialize(options) ⇒ Job
Returns a new instance of Job.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_queue/job.rb', line 18 def initialize() @options = @val = [:val] || ["val"] @job_klass = [:job_klass] || ["job_klass"] @queue = [:queue_name] ? [:queue_name].to_sym : :file_queue @queue_adapter = [:adapter] ? [:adapter] : Adapter::DefaultAdapter.new if @queue_adapter.class == String @queue_adapter = adapters[@queue_adapter] ? adapters[@queue_adapter].new : nil end end |
Instance Attribute Details
#job_klass ⇒ Object
Returns the value of attribute job_klass.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def job_klass @job_klass end |
#options ⇒ Object
Returns the value of attribute options.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def @options end |
#perform_action ⇒ Object
Returns the value of attribute perform_action.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def perform_action @perform_action end |
#queue ⇒ Object
Returns the value of attribute queue.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def queue @queue end |
#queue_adapter ⇒ Object
Returns the value of attribute queue_adapter.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def queue_adapter @queue_adapter end |
#queue_name ⇒ Object
Returns the value of attribute queue_name.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def queue_name @queue_name end |
#val ⇒ Object
Returns the value of attribute val.
17 18 19 |
# File 'lib/active_queue/job.rb', line 17 def val @val end |
Instance Method Details
#adapters ⇒ Object
def self.perform(value)
#@value ||= options[:value]
value.preform
#success = true
#begin
#@options[:value].perform
#rescue Exception => e
# success = e.message
#end
#success
end
def enqueue
@queue_adapter.enqueue(ActiveQueue::Job, @value)
end
52 53 54 55 56 |
# File 'lib/active_queue/job.rb', line 52 def adapters { "resque" => ActiveQueue::Adapter::ResqueAdapter, "delayed" => ActiveQueue::Adapter::DelayedJobAdapter, "insta" => ActiveQueue::Adapter::DefaultAdapter } end |
#enqueue ⇒ Object
33 34 35 |
# File 'lib/active_queue/job.rb', line 33 def enqueue @queue_adapter.enqueue(self.class, :val => @val, :job_klass => @job_klass) end |
#perform(opt = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/active_queue/job.rb', line 28 def perform(opt = nil) #puts "lperf #{opt[:val].respond_to?('perform')}" opt ||= self. ActiveQueue::Job.perform(opt) end |