Class: Bitcoin::Wallet::Publisher
- Inherits:
-
Concurrent::Actor::RestartingContext
- Object
- Concurrent::Actor::RestartingContext
- Bitcoin::Wallet::Publisher
- Defined in:
- lib/bitcoin/wallet/publisher.rb
Instance Attribute Summary collapse
-
#receivers ⇒ Object
readonly
Returns the value of attribute receivers.
Instance Method Summary collapse
-
#initialize ⇒ Publisher
constructor
A new instance of Publisher.
- #on_message(message) ⇒ Object
Constructor Details
#initialize ⇒ Publisher
Returns a new instance of Publisher.
8 9 10 |
# File 'lib/bitcoin/wallet/publisher.rb', line 8 def initialize @receivers = {} end |
Instance Attribute Details
#receivers ⇒ Object (readonly)
Returns the value of attribute receivers.
6 7 8 |
# File 'lib/bitcoin/wallet/publisher.rb', line 6 def receivers @receivers end |
Instance Method Details
#on_message(message) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bitcoin/wallet/publisher.rb', line 12 def () case when :unsubscribe receivers.each { |receiver| receiver.delete(envelope.sender) } when Array if [0] == :subscribe if envelope.sender.is_a? Concurrent::Actor::Reference receivers[[1].name] ||= [] receivers[[1].name] << envelope.sender end elsif [0] == :subscribe? receivers[[1].name]&.include?(envelope.sender) elsif [0] == :unsubscribe receivers.delete([1].name) end else receivers[&.class&.name]&.each { |r| r << } end end |