Class: Cod::Beanstalk::Channel::Control
- Inherits:
-
Object
- Object
- Cod::Beanstalk::Channel::Control
- Defined in:
- lib/cod/beanstalk/channel.rb
Overview
Holds a message id of a reserved message. Allows several commands to be executed on the message. See #try_get.
Instance Attribute Summary collapse
-
#msg_id ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #bury ⇒ Object
- #command_given? ⇒ Boolean
- #delete ⇒ Object
-
#initialize(msg_id, channel) ⇒ Control
constructor
A new instance of Control.
- #release ⇒ Object
- #release_with_delay(seconds) ⇒ Object
Constructor Details
#initialize(msg_id, channel) ⇒ Control
Returns a new instance of Control.
95 96 97 98 99 |
# File 'lib/cod/beanstalk/channel.rb', line 95 def initialize(msg_id, channel) @msg_id = msg_id @channel = channel @command_given = false end |
Instance Attribute Details
#msg_id ⇒ Object (readonly)
:nodoc:
93 94 95 |
# File 'lib/cod/beanstalk/channel.rb', line 93 def msg_id @msg_id end |
Instance Method Details
#bury ⇒ Object
120 121 122 123 |
# File 'lib/cod/beanstalk/channel.rb', line 120 def bury @command_given = true @channel.bs_bury(@msg_id) end |
#command_given? ⇒ Boolean
101 102 103 |
# File 'lib/cod/beanstalk/channel.rb', line 101 def command_given? @command_given end |
#delete ⇒ Object
105 106 107 108 |
# File 'lib/cod/beanstalk/channel.rb', line 105 def delete @command_given = true @channel.bs_delete(@msg_id) end |
#release ⇒ Object
109 110 111 112 |
# File 'lib/cod/beanstalk/channel.rb', line 109 def release @command_given = true @channel.bs_release(@msg_id) end |
#release_with_delay(seconds) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/cod/beanstalk/channel.rb', line 113 def release_with_delay(seconds) fail ArgumentError, "Only integer number of seconds are allowed." \ unless seconds.floor == seconds @command_given = true @channel.bs_release_with_delay(@msg_id, seconds) end |