Class: Ably::Util::PubSub
- Inherits:
-
Object
- Object
- Ably::Util::PubSub
- Includes:
- Modules::EventEmitter
- Defined in:
- lib/ably/util/pub_sub.rb
Overview
PubSub class provides methods to publish & subscribe to events, with methods and naming intentionally different to EventEmitter as it is intended for private message handling within the client library.
Class Method Summary collapse
-
.new(options = {}) ⇒ Object
Ensure new PubSub object does not share class instance variables.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PubSub
constructor
A new instance of PubSub.
- #inspect ⇒ Object
Methods included from Modules::EventEmitter
#emit, #off, #on, #once, #unsafe_on, #unsafe_once
Constructor Details
#initialize(options = {}) ⇒ PubSub
Returns a new instance of PubSub.
35 36 37 38 39 40 41 42 43 |
# File 'lib/ably/util/pub_sub.rb', line 35 def initialize( = {}) self.class.instance_eval do configure_event_emitter alias_method :subscribe, :unsafe_on alias_method :publish, :emit alias_method :unsubscribe, :off end end |
Class Method Details
.new(options = {}) ⇒ Object
Ensure new PubSub object does not share class instance variables
25 26 27 28 29 |
# File 'lib/ably/util/pub_sub.rb', line 25 def self.new( = {}) Class.new(PubSub).allocate.tap do |pub_sub_object| pub_sub_object.send(:initialize, ) end end |
Instance Method Details
#inspect ⇒ Object
31 32 33 |
# File 'lib/ably/util/pub_sub.rb', line 31 def inspect "<#PubSub: @event_emitter_coerce_proc: #{self.class.event_emitter_coerce_proc.inspect}\n @callbacks: #{callbacks}>" end |