Module: Mailmate::Identity

Extended by:
Identity
Included in:
Identity
Defined in:
lib/mailmate/identity.rb

Overview

“Is this address one of mine?” — answered against the identity list configured at ‘Mailmate.config.identities`. Personal data lives in user config (YAML or env vars), never in the gem source. This is the canonical public surface; `Mailmate::Config` is data-only.

Instance Method Summary collapse

Instance Method Details

#listObject

The configured identity list, as an array of lowercase strings.



24
25
26
# File 'lib/mailmate/identity.rb', line 24

def list
  Mailmate.config.identities.map { |a| a.to_s.downcase.strip }
end

#mine?(address) ⇒ Boolean

Returns true if ‘address` matches any configured identity (case-insensitive, whitespace-trimmed). Returns false for nil / empty input, and false when no identities are configured — the “I don’t know who you are yet” state, deliberately safe rather than surprising.

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/mailmate/identity.rb', line 17

def mine?(address)
  return false if address.nil? || address.to_s.empty?
  addr = address.to_s.downcase.strip
  list.include?(addr)
end

#reject_mine(addresses) ⇒ Object

Reject “my” addresses from an array. Useful for “who’s the other party in this conversation?” — pass the To/Cc/Bcc list, get back just the external addresses.



31
32
33
# File 'lib/mailmate/identity.rb', line 31

def reject_mine(addresses)
  Array(addresses).reject { |a| mine?(a.to_s) }
end