Class: EM::Beanstalk::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/em-beanstalk/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn, id, body) ⇒ Job

Returns a new instance of Job.



8
9
10
11
12
13
14
15
# File 'lib/em-beanstalk/job.rb', line 8

def initialize(conn, id, body)
  @conn = conn
  @id = id && Integer(id)
  @body = body
  @priority = conn && conn.default_priority
  @delay = conn && conn.default_delay
  @ttr = conn && conn.default_ttr
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/em-beanstalk/job.rb', line 6

def body
  @body
end

#connObject (readonly)

Returns the value of attribute conn.



5
6
7
# File 'lib/em-beanstalk/job.rb', line 5

def conn
  @conn
end

#delayObject

Returns the value of attribute delay.



6
7
8
# File 'lib/em-beanstalk/job.rb', line 6

def delay
  @delay
end

#idObject (readonly) Also known as: jobid

Returns the value of attribute id.



5
6
7
# File 'lib/em-beanstalk/job.rb', line 5

def id
  @id
end

#priorityObject

Returns the value of attribute priority.



6
7
8
# File 'lib/em-beanstalk/job.rb', line 6

def priority
  @priority
end

#ttrObject

Returns the value of attribute ttr.



6
7
8
# File 'lib/em-beanstalk/job.rb', line 6

def ttr
  @ttr
end

Instance Method Details

#delete(&block) ⇒ Object



19
20
21
# File 'lib/em-beanstalk/job.rb', line 19

def delete(&block)
  conn.delete(self, &block)
end

#release(delay = 0, &block) ⇒ Object



23
24
25
# File 'lib/em-beanstalk/job.rb', line 23

def release(delay = 0, &block)
  conn.release(self, :delay => delay, :priority => priority, &block)
end

#stats(&block) ⇒ Object



27
28
29
# File 'lib/em-beanstalk/job.rb', line 27

def stats(&block)
  conn.stats(:job, self, &block)
end

#to_sObject



31
32
33
# File 'lib/em-beanstalk/job.rb', line 31

def to_s
  "#{id} -- #{body.inspect}"
end