Class: MockBeaneater::Job
- Inherits:
-
Object
- Object
- MockBeaneater::Job
- Defined in:
- lib/mock_beaneater/job/record.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pri ⇒ Object
readonly
Returns the value of attribute pri.
-
#reserved ⇒ Object
readonly
Returns the value of attribute reserved.
-
#tube ⇒ Object
readonly
Returns the value of attribute tube.
-
#visible_at ⇒ Object
readonly
Returns the value of attribute visible_at.
Instance Method Summary collapse
- #==(other_job) ⇒ Object
- #delete ⇒ Object
-
#initialize(body, tube, visible_at = Time.now.to_i, pri = 65536) ⇒ Job
constructor
A new instance of Job.
- #release(options = {}) ⇒ Object
- #reserved? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(body, tube, visible_at = Time.now.to_i, pri = 65536) ⇒ Job
Returns a new instance of Job.
5 6 7 8 9 10 11 12 |
# File 'lib/mock_beaneater/job/record.rb', line 5 def initialize(body, tube, visible_at = Time.now.to_i, pri = 65536) @id = (Jobs.count += 1) @body = body @tube = tube @visible_at = visible_at @pri = pri @reserved = false end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def body @body end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def connection @connection end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def id @id end |
#pri ⇒ Object (readonly)
Returns the value of attribute pri.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def pri @pri end |
#reserved ⇒ Object (readonly)
Returns the value of attribute reserved.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def reserved @reserved end |
#tube ⇒ Object (readonly)
Returns the value of attribute tube.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def tube @tube end |
#visible_at ⇒ Object (readonly)
Returns the value of attribute visible_at.
3 4 5 |
# File 'lib/mock_beaneater/job/record.rb', line 3 def visible_at @visible_at end |
Instance Method Details
#==(other_job) ⇒ Object
32 33 34 |
# File 'lib/mock_beaneater/job/record.rb', line 32 def ==(other_job) @id == other_job.id end |
#delete ⇒ Object
21 22 23 24 25 26 |
# File 'lib/mock_beaneater/job/record.rb', line 21 def delete @reserved = false @tube.delete(self) {:status => "DELETED", :body => nil} end |
#release(options = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/mock_beaneater/job/record.rb', line 14 def release(={}) @reserved = false @tube.release(self) {:status => "RELEASED", :body => nil} end |
#reserved? ⇒ Boolean
28 29 30 |
# File 'lib/mock_beaneater/job/record.rb', line 28 def reserved? @reserved end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/mock_beaneater/job/record.rb', line 36 def to_s "#<MockBeaneater::Job id=#{@id} body=#{@body.inspect}>" end |