Class: Tina4::DevMessengerProxy
- Inherits:
-
Object
- Object
- Tina4::DevMessengerProxy
- Defined in:
- lib/tina4/messenger.rb
Overview
Proxy that wraps DevMailbox with the same interface as Messenger#send
Instance Attribute Summary collapse
-
#mailbox ⇒ Object
readonly
Returns the value of attribute mailbox.
Instance Method Summary collapse
- #folders ⇒ Object
- #inbox(**args) ⇒ Object
-
#initialize(mailbox, **options) ⇒ DevMessengerProxy
constructor
A new instance of DevMessengerProxy.
- #read ⇒ Object
- #search(**args) ⇒ Object
- #send(to:, subject:, body:, html: false, cc: [], bcc: [], reply_to: nil, attachments: [], headers: {}) ⇒ Object
- #test_connection ⇒ Object
- #unread ⇒ Object
Constructor Details
#initialize(mailbox, **options) ⇒ DevMessengerProxy
Returns a new instance of DevMessengerProxy.
567 568 569 570 571 |
# File 'lib/tina4/messenger.rb', line 567 def initialize(mailbox, **) @mailbox = mailbox @from_address = [:from_address] || ENV["TINA4_MAIL_FROM"] || "dev@localhost" @from_name = [:from_name] || ENV["TINA4_MAIL_FROM_NAME"] || "Dev Mailer" end |
Instance Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
565 566 567 |
# File 'lib/tina4/messenger.rb', line 565 def mailbox @mailbox end |
Instance Method Details
#folders ⇒ Object
591 |
# File 'lib/tina4/messenger.rb', line 591 def folders = ["inbox", "outbox"] |
#inbox(**args) ⇒ Object
587 |
# File 'lib/tina4/messenger.rb', line 587 def inbox(**args) = @mailbox.inbox(**args) |
#read ⇒ Object
588 |
# File 'lib/tina4/messenger.rb', line 588 def read(...) = @mailbox.read(...) |
#search(**args) ⇒ Object
590 |
# File 'lib/tina4/messenger.rb', line 590 def search(**args) = @mailbox.inbox(**args) |
#send(to:, subject:, body:, html: false, cc: [], bcc: [], reply_to: nil, attachments: [], headers: {}) ⇒ Object
573 574 575 576 577 578 579 580 581 |
# File 'lib/tina4/messenger.rb', line 573 def send(to:, subject:, body:, html: false, cc: [], bcc: [], reply_to: nil, attachments: [], headers: {}) @mailbox.capture( to: to, subject: subject, body: body, html: html, cc: cc, bcc: bcc, reply_to: reply_to, from_address: @from_address, from_name: @from_name, attachments: ) end |
#test_connection ⇒ Object
583 584 585 |
# File 'lib/tina4/messenger.rb', line 583 def test_connection { success: true, message: "DevMailbox mode — no SMTP connection needed" } end |
#unread ⇒ Object
589 |
# File 'lib/tina4/messenger.rb', line 589 def unread(...) = @mailbox.unread_count |