Class: Cod::Beanstalk::Channel::Control

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(msg_id, channel) ⇒ Control

Returns a new instance of Control.



148
149
150
151
152
# File 'lib/cod/beanstalk/channel.rb', line 148

def initialize(msg_id, channel)
  @msg_id = msg_id
  @channel = channel
  @command_given = false
end

Instance Attribute Details

#msg_idObject (readonly)

:nodoc:



146
147
148
# File 'lib/cod/beanstalk/channel.rb', line 146

def msg_id
  @msg_id
end

Instance Method Details

#buryObject



173
174
175
176
# File 'lib/cod/beanstalk/channel.rb', line 173

def bury
  @command_given = true
  @channel.bs_bury(@msg_id)
end

#command_given?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/cod/beanstalk/channel.rb', line 154

def command_given?
  @command_given
end

#deleteObject



158
159
160
161
# File 'lib/cod/beanstalk/channel.rb', line 158

def delete
  @command_given = true
  @channel.bs_delete(@msg_id)
end

#releaseObject



162
163
164
165
# File 'lib/cod/beanstalk/channel.rb', line 162

def release
  @command_given = true
  @channel.bs_release(@msg_id)
end

#release_with_delay(seconds) ⇒ Object



166
167
168
169
170
171
172
# File 'lib/cod/beanstalk/channel.rb', line 166

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