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
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
30 31 32 |
# File 'lib/pubby/stub.rb', line 30 def self.from_config(config) new end |
Instance Method Details
#channels ⇒ Object
22 23 24 |
# File 'lib/pubby/stub.rb', line 22 def channels @messages.keys end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/pubby/stub.rb', line 26 def empty? @messages.empty? || @messages.all? { |k, v| v.empty? } end |
#messages ⇒ Object
18 19 20 |
# File 'lib/pubby/stub.rb', line 18 def @messages end |
#publish(channel_name, message) ⇒ Object
13 14 15 16 |
# File 'lib/pubby/stub.rb', line 13 def publish(channel_name, ) @messages[channel_name] << true end |