Class: Delayed::FakeJob
- Inherits:
-
Object
- Object
- Delayed::FakeJob
- Defined in:
- lib/delayed/fake_job.rb
Constant Summary collapse
- @@count =
1- @@lock =
Mutex.new
Instance Attribute Summary collapse
-
#attempts ⇒ Object
Returns the value of attribute attempts.
-
#id ⇒ Object
Returns the value of attribute id.
-
#object_id ⇒ Object
Returns the value of attribute object_id.
-
#object_type ⇒ Object
Returns the value of attribute object_type.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#run_at ⇒ Object
Returns the value of attribute run_at.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(queue = nil) ⇒ FakeJob
constructor
A new instance of FakeJob.
- #invoke_job ⇒ Object
- #perform ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(queue = nil) ⇒ FakeJob
Returns a new instance of FakeJob.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/delayed/fake_job.rb', line 7 def initialize(queue=nil) @run_at = DateTime.now @attempts = 0 @queue = queue @@lock.synchronize { @id = @@count @@count += 1 } end |
Instance Attribute Details
#attempts ⇒ Object
Returns the value of attribute attempts.
5 6 7 |
# File 'lib/delayed/fake_job.rb', line 5 def attempts @attempts end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/delayed/fake_job.rb', line 5 def id @id end |
#object_id ⇒ Object
Returns the value of attribute object_id.
5 6 7 |
# File 'lib/delayed/fake_job.rb', line 5 def object_id @object_id end |
#object_type ⇒ Object
Returns the value of attribute object_type.
5 6 7 |
# File 'lib/delayed/fake_job.rb', line 5 def object_type @object_type end |
#queue ⇒ Object
Returns the value of attribute queue.
5 6 7 |
# File 'lib/delayed/fake_job.rb', line 5 def queue @queue end |
#run_at ⇒ Object
Returns the value of attribute run_at.
5 6 7 |
# File 'lib/delayed/fake_job.rb', line 5 def run_at @run_at end |
Instance Method Details
#delete ⇒ Object
27 28 29 |
# File 'lib/delayed/fake_job.rb', line 27 def delete DelayedJobActiveRecordThreaded.logger.info "deleting job #{@id}" if DelayedJobActiveRecordThreaded.logger end |
#invoke_job ⇒ Object
18 19 20 21 |
# File 'lib/delayed/fake_job.rb', line 18 def invoke_job DelayedJobActiveRecordThreaded.logger.info "invoking job #{@id} in queue #{@queue}" if DelayedJobActiveRecordThreaded.logger sleep(rand * 5) end |
#perform ⇒ Object
23 24 25 |
# File 'lib/delayed/fake_job.rb', line 23 def perform invoke_job end |
#save ⇒ Object
31 32 33 |
# File 'lib/delayed/fake_job.rb', line 31 def save DelayedJobActiveRecordThreaded.logger "saving job #{@id}" if DelayedJobActiveRecordThreaded.logger end |