Class: Kiqit::JobCreator
- Inherits:
-
Object
- Object
- Kiqit::JobCreator
- Defined in:
- lib/kiqit/job_creator.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#klass_name ⇒ Object
readonly
Returns the value of attribute klass_name.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Instance Method Summary collapse
- #enqueue(delay = nil) ⇒ Object
-
#initialize(queue, worker, klass_name, id, method, *args) ⇒ JobCreator
constructor
A new instance of JobCreator.
Constructor Details
#initialize(queue, worker, klass_name, id, method, *args) ⇒ JobCreator
Returns a new instance of JobCreator.
7 8 9 10 11 12 13 14 |
# File 'lib/kiqit/job_creator.rb', line 7 def initialize(queue, worker, klass_name, id, method, *args) @queue = queue @worker = worker @klass_name = klass_name @id = id @method = method @args = args end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
5 6 7 |
# File 'lib/kiqit/job_creator.rb', line 5 def args @args end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/kiqit/job_creator.rb', line 4 def id @id end |
#klass_name ⇒ Object (readonly)
Returns the value of attribute klass_name.
4 5 6 |
# File 'lib/kiqit/job_creator.rb', line 4 def klass_name @klass_name end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
4 5 6 |
# File 'lib/kiqit/job_creator.rb', line 4 def method @method end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
4 5 6 |
# File 'lib/kiqit/job_creator.rb', line 4 def queue @queue end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
4 5 6 |
# File 'lib/kiqit/job_creator.rb', line 4 def worker @worker end |
Instance Method Details
#enqueue(delay = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kiqit/job_creator.rb', line 16 def enqueue(delay=nil) params = {} if delay delay = delay.is_a?(Hash) ? delay[:delay] : delay params["at"] = (Time.now + delay).to_i end params.merge!({"queue" => queue, "class" => worker, "args" => [klass_name, id, method, *args]}) Sidekiq::Client.push(params) end |