Class: Postpeek::Metadata::Builder
- Inherits:
-
Object
- Object
- Postpeek::Metadata::Builder
- Defined in:
- lib/postpeek/metadata/builder.rb
Instance Method Summary collapse
-
#build ⇒ Hash
Pipeline: 1.
-
#initialize(mail, config:, delivery_duration_ms: nil) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(mail, config:, delivery_duration_ms: nil) ⇒ Builder
Returns a new instance of Builder.
9 10 11 12 13 |
# File 'lib/postpeek/metadata/builder.rb', line 9 def initialize(mail, config:, delivery_duration_ms: nil) @mail = mail @config = config @delivery_duration_ms = delivery_duration_ms end |
Instance Method Details
#build ⇒ Hash
Pipeline:
- Extractor#to_h — base fields
- mailer_class + mailer_action from ActionMailerContext (fallback: X-Postpeek-* headers when thread context is nil)
- id = IdGenerator.generate
- delivery_duration_ms (from arg)
- tags: []
- Call each config.metadata_builders callable(hash); merge result
24 25 26 27 28 29 30 31 32 |
# File 'lib/postpeek/metadata/builder.rb', line 24 def build hash = Extractor.new(mail).to_h hash[:mailer_class] = mailer_class_value hash[:mailer_action] = mailer_action_value hash[:id] = IdGenerator.generate hash[:delivery_duration_ms] = delivery_duration_ms hash[:tags] = [] (hash) end |