Class: MailDude::MessageSerializer
- Inherits:
-
Object
- Object
- MailDude::MessageSerializer
- Defined in:
- lib/mail_dude/message_serializer.rb
Constant Summary collapse
- INTERNAL_MAILER_HEADER =
'X-Mail-Dude-Mailer'- INTERNAL_ACTION_HEADER =
'X-Mail-Dude-Action'
Instance Attribute Summary collapse
-
#captured_at ⇒ Object
readonly
Returns the value of attribute captured_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mail ⇒ Object
readonly
Returns the value of attribute mail.
-
#raw_source ⇒ Object
readonly
Returns the value of attribute raw_source.
Instance Method Summary collapse
-
#initialize(mail, id:, captured_at:, raw_source: nil) ⇒ MessageSerializer
constructor
A new instance of MessageSerializer.
- #metadata ⇒ Object
Constructor Details
#initialize(mail, id:, captured_at:, raw_source: nil) ⇒ MessageSerializer
Returns a new instance of MessageSerializer.
10 11 12 13 14 15 |
# File 'lib/mail_dude/message_serializer.rb', line 10 def initialize(mail, id:, captured_at:, raw_source: nil) @mail = mail @id = id @captured_at = captured_at.utc @raw_source = raw_source || mail.to_s end |
Instance Attribute Details
#captured_at ⇒ Object (readonly)
Returns the value of attribute captured_at.
8 9 10 |
# File 'lib/mail_dude/message_serializer.rb', line 8 def captured_at @captured_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/mail_dude/message_serializer.rb', line 8 def id @id end |
#mail ⇒ Object (readonly)
Returns the value of attribute mail.
8 9 10 |
# File 'lib/mail_dude/message_serializer.rb', line 8 def mail @mail end |
#raw_source ⇒ Object (readonly)
Returns the value of attribute raw_source.
8 9 10 |
# File 'lib/mail_dude/message_serializer.rb', line 8 def raw_source @raw_source end |
Instance Method Details
#metadata ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mail_dude/message_serializer.rb', line 17 def { 'id' => id, 'captured_at' => captured_at.iso8601(6), 'subject' => decoded_subject, 'from' => addresses(:from), 'sender' => addresses(:sender), 'to' => addresses(:to), 'cc' => addresses(:cc), 'bcc' => addresses(:bcc), 'reply_to' => addresses(:reply_to), 'date' => date_value, 'message_id' => header_value(:message_id), 'in_reply_to' => header_value(:in_reply_to), 'references' => references, 'content_type' => content_type, 'mime_version' => header_value(:mime_version), 'mailer' => internal_header(INTERNAL_MAILER_HEADER), 'mailer_action' => internal_header(INTERNAL_ACTION_HEADER), 'has_html' => part_present?('text/html'), 'has_text' => part_present?('text/plain'), 'has_attachments' => .any?, 'attachments_count' => .length, 'attachments' => , 'size_bytes' => raw_source.bytesize } end |