Class: Mailkube::Events::MessageContext

Inherits:
Node
  • Object
show all
Defined in:
lib/mailkube/events/contexts.rb,
sig/mailkube/events/contexts.rbs

Overview

The message an event is about: the fields every email.* event carries.

The shared base of all nine email.* payloads, mirroring the server, where one serializer supplies this block to every message event.

Every field except the id and timestamp is nullable: they are denormalized from the send transaction, and there is a window in which an event can be emitted before that row exists.

Instance Attribute Summary

Attributes inherited from Node

#raw

Instance Method Summary collapse

Methods inherited from Node

#==, #[], #block, #hash, #initialize, #to_h

Constructor Details

This class inherits a constructor from Mailkube::Events::Node

Instance Method Details

#created_atString

Returns when the message was accepted.

Returns:

  • (String)

    when the message was accepted.



16
17
# File 'lib/mailkube/events/contexts.rb', line 16

def created_at = self["created_at"]
# @return [String, nil] the sending domain.

#domainString?

Returns the sending domain.

Returns:

  • (String, nil)

    the sending domain.



18
19
# File 'lib/mailkube/events/contexts.rb', line 18

def domain = self["domain"]
# @return [String, nil] the subject line.

#email_idString

Returns the message's UUID.

Returns:

  • (String)

    the message's UUID.



14
15
# File 'lib/mailkube/events/contexts.rb', line 14

def email_id = self["email_id"]
# @return [String] when the message was accepted.

#fromString?

from is the wire key and is neither a Ruby keyword nor an Object method, so it needs no renaming — unlike Python, where from_ is forced.

Returns:

  • (String, nil)

    the sender address.



26
# File 'lib/mailkube/events/contexts.rb', line 26

def from = self["from"]

#subjectString?

Returns the subject line.

Returns:

  • (String, nil)

    the subject line.



20
21
# File 'lib/mailkube/events/contexts.rb', line 20

def subject = self["subject"]
# @return [Array<String>, nil] the recipients.

#tagsArray[Hash[String, untyped]]

Plain hashes, not Mailkube::Tag: a Data would drop an unknown key inside a tag.

Returns:

  • (Array[Hash[String, untyped]])


37
# File 'lib/mailkube/events/contexts.rb', line 37

def tags = self["tags"] || []

#toArray<String>?

Returns the recipients.

Returns:

  • (Array<String>, nil)

    the recipients.



22
23
24
25
# File 'lib/mailkube/events/contexts.rb', line 22

def to = self["to"]
# `from` is the wire key and is neither a Ruby keyword nor an Object method, so it needs no
# renaming — unlike Python, where `from_` is forced.
# @return [String, nil] the sender address.