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.
561 562 563 564 565 |
# File 'lib/tina4/messenger.rb', line 561 def initialize(mailbox, **) @mailbox = mailbox @from_address = [:from_address] || ENV["TINA4_MAIL_FROM"] || ENV["SMTP_FROM"] || "dev@localhost" @from_name = [:from_name] || ENV["TINA4_MAIL_FROM_NAME"] || ENV["SMTP_FROM_NAME"] || "Dev Mailer" end |
Instance Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
559 560 561 |
# File 'lib/tina4/messenger.rb', line 559 def mailbox @mailbox end |
Instance Method Details
#folders ⇒ Object
585 |
# File 'lib/tina4/messenger.rb', line 585 def folders = ["inbox", "outbox"] |
#inbox(**args) ⇒ Object
581 |
# File 'lib/tina4/messenger.rb', line 581 def inbox(**args) = @mailbox.inbox(**args) |
#read ⇒ Object
582 |
# File 'lib/tina4/messenger.rb', line 582 def read(...) = @mailbox.read(...) |
#search(**args) ⇒ Object
584 |
# File 'lib/tina4/messenger.rb', line 584 def search(**args) = @mailbox.inbox(**args) |
#send(to:, subject:, body:, html: false, cc: [], bcc: [], reply_to: nil, attachments: [], headers: {}) ⇒ Object
567 568 569 570 571 572 573 574 575 |
# File 'lib/tina4/messenger.rb', line 567 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
577 578 579 |
# File 'lib/tina4/messenger.rb', line 577 def test_connection { success: true, message: "DevMailbox mode — no SMTP connection needed" } end |
#unread ⇒ Object
583 |
# File 'lib/tina4/messenger.rb', line 583 def unread(...) = @mailbox.unread_count |