Class: Postpeek::DeliveryMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/postpeek/delivery_method.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ DeliveryMethod



6
7
8
# File 'lib/postpeek/delivery_method.rb', line 6

def initialize(settings = {})
  @settings = settings
end

Instance Method Details

#deliver!(mail) ⇒ Object

Full pipeline:

  1. Record start time
  2. Decode parts (html_body, text_body, attachments)
  3. Compute delivery_duration_ms
  4. Build metadata via Metadata::Builder
  5. Construct Message value object
  6. Persist via storage backend
  7. Run after_save hooks


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/postpeek/delivery_method.rb', line 18

def deliver!(mail)
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  html_body, text_body, attachments = decode_parts(mail)
  duration_ms = elapsed_ms(start_time)

   = ::Builder.new(mail, config: config, delivery_duration_ms: duration_ms).build
  message  = Message.new(mail: mail, metadata: ,
                         html_body: html_body, text_body: text_body, attachments: attachments)

  storage.save(message)
  Hooks::Lifecycle.run_after_save(message, config: config)
end