Class: Informator::Reporter Private
- Inherits:
-
Object
- Object
- Informator::Reporter
- Defined in:
- lib/informator/reporter.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.
Builds, collects and publishes events to selected subscribers
Instance Attribute Summary collapse
-
#events ⇒ Array<Informator::Event>
readonly
private
The list of registered events that havent’b been published yet.
Instance Method Summary collapse
-
#initialize ⇒ Reporter
constructor
private
A new instance of Reporter.
-
#notify(*subscribers) ⇒ Array<Informator::Event>
private
Notifies subscribers on events registered since the last notification.
-
#remember(type, messages, attributes) ⇒ self
private
Registers the event to be published to subscribers.
Constructor Details
#initialize ⇒ Reporter
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 a new instance of Reporter.
23 24 25 26 |
# File 'lib/informator/reporter.rb', line 23 def initialize @events = [] freeze # freezes the instance, but left events mutable! end |
Instance Attribute Details
#events ⇒ Array<Informator::Event> (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 list of registered events that havent’b been published yet.
31 32 33 |
# File 'lib/informator/reporter.rb', line 31 def events @events end |
Instance Method Details
#notify(*subscribers) ⇒ Array<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.
Notifies subscribers on events registered since the last notification
Mutates [#events] by excluding all events having been published.
54 55 56 |
# File 'lib/informator/reporter.rb', line 54 def notify(*subscribers) events.dup.each { publish subscribers.flatten } end |
#remember(type, messages, attributes) ⇒ self
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.
Registers the event to be published to subscribers
40 41 42 43 44 |
# File 'lib/informator/reporter.rb', line 40 def remember(*args) events << Event.new(*args) self end |