Class: Omnes::PublicationContext
- Inherits:
-
Object
- Object
- Omnes::PublicationContext
- Defined in:
- lib/omnes/publication_context.rb
Overview
Context for an event publication
An instance of this class is shared between all the executions that are triggered by the publication of a given event. It's provided to the subscriptions as their second argument when they take it.
This class is useful mainly for debugging and logging purposes.
Instance Attribute Summary collapse
-
#caller_location ⇒ Thread::Backtrace::Location
readonly
Location for the event publisher.
-
#time ⇒ Time
readonly
Time of the event publication.
Instance Method Summary collapse
-
#initialize(caller_location:, time:) ⇒ PublicationContext
constructor
private
A new instance of PublicationContext.
-
#serialized ⇒ Object
Serialized version of a publication context.
Constructor Details
#initialize(caller_location:, time:) ⇒ PublicationContext
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 PublicationContext.
26 27 28 29 |
# File 'lib/omnes/publication_context.rb', line 26 def initialize(caller_location:, time:) @caller_location = caller_location @time = time end |
Instance Attribute Details
#caller_location ⇒ Thread::Backtrace::Location (readonly)
Location for the event publisher
It's set by Bus#publish, and it points to the caller of that method.
18 19 20 |
# File 'lib/omnes/publication_context.rb', line 18 def caller_location @caller_location end |
#time ⇒ Time (readonly)
Time of the event publication
23 24 25 |
# File 'lib/omnes/publication_context.rb', line 23 def time @time end |
Instance Method Details
#serialized ⇒ Object
Serialized version of a publication context
34 35 36 37 38 39 |
# File 'lib/omnes/publication_context.rb', line 34 def serialized { "caller_location" => caller_location.to_s, "time" => time.to_s } end |