Class: Pubby::Stub
- Inherits:
-
Object
- Object
- Pubby::Stub
- Defined in:
- lib/pubby/stub.rb
Class Method Summary collapse
Instance Method Summary collapse
- #channels ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(initial_messages = {}) ⇒ Stub
constructor
A new instance of Stub.
- #messages ⇒ Object
- #publish(channel_name, message) ⇒ Object
Constructor Details
#initialize(initial_messages = {}) ⇒ Stub
Returns a new instance of Stub.
3 4 5 6 7 8 9 10 11 |
# File 'lib/pubby/stub.rb', line 3 def initialize( = {}) @messages = Hash.new { |h, k| h[k] = [] } .each do |channel, | .each do || publish(channel, ) end end end |
Class Method Details
.from_config(config) ⇒ Object
29 30 31 |
# File 'lib/pubby/stub.rb', line 29 def self.from_config(config) new end |
Instance Method Details
#channels ⇒ Object
21 22 23 |
# File 'lib/pubby/stub.rb', line 21 def channels @messages.keys end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/pubby/stub.rb', line 25 def empty? @messages.empty? || @messages.all? { |k, v| v.empty? } end |
#messages ⇒ Object
17 18 19 |
# File 'lib/pubby/stub.rb', line 17 def @messages end |
#publish(channel_name, message) ⇒ Object
13 14 15 |
# File 'lib/pubby/stub.rb', line 13 def publish(channel_name, ) @messages[channel_name] << end |