Module: Mailmate::Identity
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
-
#list ⇒ Object
The configured identity list, as an array of lowercase strings.
-
#mine?(address) ⇒ Boolean
Returns true if ‘address` matches any configured identity (case-insensitive, whitespace-trimmed).
-
#reject_mine(addresses) ⇒ Object
Reject “my” addresses from an array.
Instance Method Details
#list ⇒ Object
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.
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 |