Class: Smith::Messaging::MessageCounter
- Inherits:
-
Object
- Object
- Smith::Messaging::MessageCounter
- Defined in:
- lib/smith/messaging/message_counter.rb
Instance Method Summary collapse
-
#counter ⇒ Object
Return the total number of messages sent or received for the named queue.
- #increment_counter(value = 1) ⇒ Object
-
#initialize(queue_name) ⇒ MessageCounter
constructor
A new instance of MessageCounter.
Constructor Details
#initialize(queue_name) ⇒ MessageCounter
Returns a new instance of MessageCounter.
6 7 8 9 |
# File 'lib/smith/messaging/message_counter.rb', line 6 def initialize(queue_name) @message_counts = Hash.new(0) @queue_name = queue_name end |
Instance Method Details
#counter ⇒ Object
Return the total number of messages sent or received for the named queue.
12 13 14 |
# File 'lib/smith/messaging/message_counter.rb', line 12 def counter @message_counts[@queue_name] end |
#increment_counter(value = 1) ⇒ Object
16 17 18 |
# File 'lib/smith/messaging/message_counter.rb', line 16 def increment_counter(value=1) @message_counts[@queue_name] += value end |