Class: Gcpc::Interceptors::Publisher::IdInterceptor
- Inherits:
-
Publisher::BaseInterceptor
- Object
- Publisher::BaseInterceptor
- Gcpc::Interceptors::Publisher::IdInterceptor
- Defined in:
- lib/gcpc/interceptors/publisher/id_interceptor.rb
Overview
‘IdInterceptor` adds an unique id to a message’s attributes
Constant Summary collapse
- DEFAULT_ID_KEY =
"message_id"
Instance Method Summary collapse
-
#initialize(id_key: DEFAULT_ID_KEY) ⇒ IdInterceptor
constructor
A new instance of IdInterceptor.
- #publish(data, attributes) {|data, a| ... } ⇒ Object
Constructor Details
#initialize(id_key: DEFAULT_ID_KEY) ⇒ IdInterceptor
Returns a new instance of IdInterceptor.
10 11 12 |
# File 'lib/gcpc/interceptors/publisher/id_interceptor.rb', line 10 def initialize(id_key: DEFAULT_ID_KEY) @id_key = id_key end |
Instance Method Details
#publish(data, attributes) {|data, a| ... } ⇒ Object
16 17 18 19 |
# File 'lib/gcpc/interceptors/publisher/id_interceptor.rb', line 16 def publish(data, attributes) a = attributes.merge(@id_key => id) yield data, a end |