Module: Mailtrap::Mail

Defined in:
lib/mailtrap/mail.rb,
lib/mailtrap/mail/base.rb,
lib/mailtrap/mail/from_template.rb

Defined Under Namespace

Classes: Base, FromTemplate

Class Method Summary collapse

Class Method Details

.from_message(message) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mailtrap/mail.rb', line 11

def from_message(message) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
  Mailtrap::Mail::Base.new(
    from: prepare_address(address_list(message['from'])&.addresses&.first),
    to: prepare_addresses(address_list(message['to'])&.addresses),
    cc: prepare_addresses(address_list(message['cc'])&.addresses),
    bcc: prepare_addresses(address_list(message['bcc'])&.addresses),
    subject: message.subject,
    text: prepare_text_part(message),
    html: prepare_html_part(message),
    headers: prepare_headers(message),
    attachments: prepare_attachments(message.attachments),
    category: message['category']&.unparsed_value,
    custom_variables: message['custom_variables']&.unparsed_value
  )
end