Class: Informator::Subscriber Private
- Inherits:
-
Object
- Object
- Informator::Subscriber
- Defined in:
- lib/informator/subscriber.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Subscriber wraps the [#object] along with its [#callback] method to receive event notifications.
Instance Attribute Summary collapse
-
#callback ⇒ Symbol
readonly
private
The name of the object methods to listen to events.
-
#object ⇒ Object
readonly
private
The object to send events to.
Class Method Summary collapse
- .initialize(object, callback = :receive) ⇒ Object private
-
.new(object, callback) ⇒ Informator::Subscriber
Builds the subscriber for given object and callback.
-
.notify(event) ⇒ Informator::Event
private
Sends the event to the subscriber object via its callback.
Instance Attribute Details
#callback ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the name of the object methods to listen to events.
36 37 38 |
# File 'lib/informator/subscriber.rb', line 36 def callback @callback end |
#object ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the object to send events to.
30 31 32 |
# File 'lib/informator/subscriber.rb', line 30 def object @object end |
Class Method Details
.initialize(object, callback = :receive) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 |
# File 'lib/informator/subscriber.rb', line 48 def initialize(object, callback = :receive) @object = object @callback = callback.to_sym IceNine.deep_freeze(self) end |
.new(object, callback) ⇒ Informator::Subscriber
Builds the subscriber for given object and callback
|
|
# File 'lib/informator/subscriber.rb', line 38
|
.notify(event) ⇒ Informator::Event
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sends the event to the subscriber object via its callback
60 61 62 63 64 |
# File 'lib/informator/subscriber.rb', line 60 def notify(event) object.public_send callback, event event end |