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.
536 537 538 539 540 |
# File 'lib/tina4/messenger.rb', line 536 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.
534 535 536 |
# File 'lib/tina4/messenger.rb', line 534 def mailbox @mailbox end |
Instance Method Details
#folders ⇒ Object
560 |
# File 'lib/tina4/messenger.rb', line 560 def folders = ["inbox", "outbox"] |
#inbox(**args) ⇒ Object
556 |
# File 'lib/tina4/messenger.rb', line 556 def inbox(**args) = @mailbox.inbox(**args) |
#read ⇒ Object
557 |
# File 'lib/tina4/messenger.rb', line 557 def read(...) = @mailbox.read(...) |
#search(**args) ⇒ Object
559 |
# File 'lib/tina4/messenger.rb', line 559 def search(**args) = @mailbox.inbox(**args) |
#send(to:, subject:, body:, html: false, cc: [], bcc: [], reply_to: nil, attachments: [], headers: {}) ⇒ Object
542 543 544 545 546 547 548 549 550 |
# File 'lib/tina4/messenger.rb', line 542 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
552 553 554 |
# File 'lib/tina4/messenger.rb', line 552 def test_connection { success: true, message: "DevMailbox mode — no SMTP connection needed" } end |
#unread ⇒ Object
558 |
# File 'lib/tina4/messenger.rb', line 558 def unread(...) = @mailbox.unread_count |