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.



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_idObject (readonly)

:nodoc:



133
134
135
# File 'lib/cod/beanstalk/channel.rb', line 133

def msg_id
  @msg_id
end

Instance Method Details

#buryObject



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

Returns:

  • (Boolean)


141
142
143
# File 'lib/cod/beanstalk/channel.rb', line 141

def command_given?
  @command_given
end

#deleteObject



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

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

#releaseObject



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