Class: Gcpc::Interceptors::Publisher::TimestampInterceptor
- Inherits:
-
Publisher::BaseInterceptor
- Object
- Publisher::BaseInterceptor
- Gcpc::Interceptors::Publisher::TimestampInterceptor
- Defined in:
- lib/gcpc/interceptors/publisher/timestamp_interceptor.rb
Overview
‘TimestampInterceptor` adds a timestamp to a message’s attributes in RFC3339 format.
Constant Summary collapse
- DEFAULT_TIMESTAMP_KEY =
"published_at"
Instance Method Summary collapse
-
#initialize(timestamp_key: DEFAULT_TIMESTAMP_KEY) ⇒ TimestampInterceptor
constructor
A new instance of TimestampInterceptor.
- #publish(data, attributes) {|data, a| ... } ⇒ Object
Constructor Details
#initialize(timestamp_key: DEFAULT_TIMESTAMP_KEY) ⇒ TimestampInterceptor
Returns a new instance of TimestampInterceptor.
11 12 13 |
# File 'lib/gcpc/interceptors/publisher/timestamp_interceptor.rb', line 11 def initialize(timestamp_key: DEFAULT_TIMESTAMP_KEY) @timestamp_key = end |
Instance Method Details
#publish(data, attributes) {|data, a| ... } ⇒ Object
17 18 19 20 |
# File 'lib/gcpc/interceptors/publisher/timestamp_interceptor.rb', line 17 def publish(data, attributes) a = attributes.merge(@timestamp_key => DateTime.now.rfc3339) yield data, a end |