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.
135 136 137 138 139 |
# File 'lib/cod/beanstalk/channel.rb', line 135 def initialize(msg_id, channel) @msg_id = msg_id @channel = channel @command_given = false end |
Instance Attribute Details
#msg_id ⇒ Object (readonly)
:nodoc:
133 134 135 |
# File 'lib/cod/beanstalk/channel.rb', line 133 def msg_id @msg_id end |
Instance Method Details
#bury ⇒ Object
160 161 162 163 |
# File 'lib/cod/beanstalk/channel.rb', line 160 def bury @command_given = true @channel.bs_bury(@msg_id) end |
#command_given? ⇒ Boolean
141 142 143 |
# File 'lib/cod/beanstalk/channel.rb', line 141 def command_given? @command_given end |
#delete ⇒ Object
145 146 147 148 |
# File 'lib/cod/beanstalk/channel.rb', line 145 def delete @command_given = true @channel.bs_delete(@msg_id) end |
#release ⇒ Object
149 150 151 152 |
# File 'lib/cod/beanstalk/channel.rb', line 149 def release @command_given = true @channel.bs_release(@msg_id) end |
#release_with_delay(seconds) ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/cod/beanstalk/channel.rb', line 153 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 |