Class: ActiveMessaging::Adapters::Adapter::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/activemessaging/adapters/wmq.rb

Overview

Queue class is used to keep track of the subscriptions It contains :

- name of the queue
- options to use when getting from the queue
- number of subscriptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, get_options) ⇒ Queue

Returns a new instance of Queue.



169
170
171
172
# File 'lib/activemessaging/adapters/wmq.rb', line 169

def initialize(name, get_options)
  @name, @get_options  = name, get_options
  @nb_subscriptions = 0
end

Instance Attribute Details

#get_optionsObject

Returns the value of attribute get_options.



167
168
169
# File 'lib/activemessaging/adapters/wmq.rb', line 167

def get_options
  @get_options
end

#nameObject

Returns the value of attribute name.



167
168
169
# File 'lib/activemessaging/adapters/wmq.rb', line 167

def name
  @name
end

#nb_subscriptionsObject

Returns the value of attribute nb_subscriptions.



167
168
169
# File 'lib/activemessaging/adapters/wmq.rb', line 167

def nb_subscriptions
  @nb_subscriptions
end

Instance Method Details

#add_subscriptionObject



174
175
176
# File 'lib/activemessaging/adapters/wmq.rb', line 174

def add_subscription
  @nb_subscriptions += 1
end

#has_subscription?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/activemessaging/adapters/wmq.rb', line 182

def has_subscription?
  @nb_subscriptions > 0
end

#remove_subscriptionObject



178
179
180
# File 'lib/activemessaging/adapters/wmq.rb', line 178

def remove_subscription
  @nb_subscriptions -= 1 unless @nb_subscriptions > 0
end

#to_sObject



186
187
188
# File 'lib/activemessaging/adapters/wmq.rb', line 186

def to_s
  "<Adapter::Queue name='#{@name}' get_options=#{@get_options} nb_subscriptions=#{@nb_subscriptions}>"
end