Class: MockBeaneater::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_beaneater/job/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/mock_beaneater/job/record.rb', line 3

def body
  @body
end

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/mock_beaneater/job/record.rb', line 3

def connection
  @connection
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/mock_beaneater/job/record.rb', line 3

def id
  @id
end

#priObject (readonly)

Returns the value of attribute pri.



3
4
5
# File 'lib/mock_beaneater/job/record.rb', line 3

def pri
  @pri
end

#reservedObject (readonly)

Returns the value of attribute reserved.



3
4
5
# File 'lib/mock_beaneater/job/record.rb', line 3

def reserved
  @reserved
end

#tubeObject (readonly)

Returns the value of attribute tube.



3
4
5
# File 'lib/mock_beaneater/job/record.rb', line 3

def tube
  @tube
end

#visible_atObject (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

#deleteObject



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(options={})
  @reserved = false
  @tube.release(self)
  {:status => "RELEASED",
   :body => nil}
end

#reserved?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mock_beaneater/job/record.rb', line 28

def reserved?
  @reserved
end

#to_sObject



36
37
38
# File 'lib/mock_beaneater/job/record.rb', line 36

def to_s
  "#<MockBeaneater::Job id=#{@id} body=#{@body.inspect}>"
end