Class: Conrad::Processors::AddUUID
- Inherits:
-
Object
- Object
- Conrad::Processors::AddUUID
- Defined in:
- lib/conrad/processors/add_uuid.rb
Overview
Generalized processor for inserting a UUID into the event. Allows configuring the key used for insertion.
Instance Attribute Summary collapse
-
#uuid_key ⇒ Object
readonly
The key inserted into the event hash for the generated UUID.
Instance Method Summary collapse
-
#call(event) ⇒ Hash
The hash with the UUID inserted.
-
#initialize(uuid_key = :event_uuid) ⇒ AddUUID
constructor
A new instance of AddUUID.
Constructor Details
#initialize(uuid_key = :event_uuid) ⇒ AddUUID
Returns a new instance of AddUUID.
15 16 17 |
# File 'lib/conrad/processors/add_uuid.rb', line 15 def initialize(uuid_key = :event_uuid) @uuid_key = uuid_key end |
Instance Attribute Details
#uuid_key ⇒ Object (readonly)
The key inserted into the event hash for the generated UUID.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/conrad/processors/add_uuid.rb', line 11 class AddUUID attr_reader :uuid_key # @param uuid_key [Symbol] key to use for the generated UUID def initialize(uuid_key = :event_uuid) @uuid_key = uuid_key end # @param event [Hash] the current event # # @return [Hash] the hash with the UUID inserted def call(event) event.merge(uuid_key => SecureRandom.uuid) end end |
Instance Method Details
#call(event) ⇒ Hash
Returns the hash with the UUID inserted.
22 23 24 |
# File 'lib/conrad/processors/add_uuid.rb', line 22 def call(event) event.merge(uuid_key => SecureRandom.uuid) end |