Class: Protege::Gateway::Mail::Outbound
- Inherits:
-
Object
- Object
- Protege::Gateway::Mail::Outbound
- Defined in:
- lib/protege/gateway/mail/outbound.rb
Overview
Builder for outbound ::Mail::Message objects — the one place the engine assembles mail it
sends, whether a brand-new console conversation or a threaded reply.
Centralizing construction keeps the conventions (a synthetic angle-bracketed Message-ID, a
UTF-8 plain-text body, a Date stamp) and the threading-header normalization (+In-Reply-To+ via
MessageId, References via References) in a single tested spot, rather than duplicated
across RepliesController, ThreadsController, and host tools like SendEmailTool.
Class Method Summary collapse
-
.build(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [], hops: nil) ⇒ ::Mail::Message
Build and return a ready-to-deliver
::Mail::Message.
Instance Method Summary collapse
-
#initialize(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [], hops: nil) ⇒ Outbound
constructor
Store the envelope and threading inputs.
-
#message ⇒ ::Mail::Message
Assemble the
::Mail::Messagefrom the stored inputs.
Constructor Details
#initialize(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [], hops: nil) ⇒ Outbound
Store the envelope and threading inputs. Prefer the .build factory.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/protege/gateway/mail/outbound.rb', line 74 def initialize( from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [], hops: nil ) @from = from @to = to @subject = subject @body = body @cc = cc @bcc = bcc @in_reply_to = in_reply_to @references = references @attachments = @hops = hops end |
Class Method Details
.build(from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [], hops: nil) ⇒ ::Mail::Message
Build and return a ready-to-deliver ::Mail::Message.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/protege/gateway/mail/outbound.rb', line 44 def build( from:, to:, subject:, body:, cc: [], bcc: [], in_reply_to: nil, references: nil, attachments: [], hops: nil ) new( from:, to:, subject:, body:, cc:, bcc:, in_reply_to:, references:, attachments:, hops: ). end |
Instance Method Details
#message ⇒ ::Mail::Message
Assemble the ::Mail::Message from the stored inputs.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/protege/gateway/mail/outbound.rb', line 101 def ::Mail.new.tap do |m| m.from = @from m.to = @to m.cc = @cc m.bcc = @bcc m.subject = @subject m. = MessageId.synthetic(domain: sender_domain).value m.date = Time.current m.in_reply_to = parent_id if parent_id m.references = reference_values if reference_values.any? stamp_hops(m) assign_content(m) end end |