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.



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

:nodoc:



93
94
95
# File 'lib/cod/beanstalk/channel.rb', line 93

def msg_id
  @msg_id
end

Instance Method Details

#buryObject



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

Returns:

  • (Boolean)


101
102
103
# File 'lib/cod/beanstalk/channel.rb', line 101

def command_given?
  @command_given
end

#deleteObject



105
106
107
108
# File 'lib/cod/beanstalk/channel.rb', line 105

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

#releaseObject



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