Class: Tina4::DevMessengerProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/tina4/messenger.rb

Overview

Proxy that wraps DevMailbox with the same interface as Messenger#send

Instance Attribute Summary collapse

Instance Method Summary collapse

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, **options)
  @mailbox = mailbox
  @from_address = options[:from_address] || ENV["TINA4_MAIL_FROM"] || ENV["SMTP_FROM"] || "dev@localhost"
  @from_name    = options[:from_name]    || ENV["TINA4_MAIL_FROM_NAME"] || ENV["SMTP_FROM_NAME"] || "Dev Mailer"
end

Instance Attribute Details

#mailboxObject (readonly)

Returns the value of attribute mailbox.



559
560
561
# File 'lib/tina4/messenger.rb', line 559

def mailbox
  @mailbox
end

Instance Method Details

#foldersObject



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)

#readObject



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: attachments
  )
end

#test_connectionObject



577
578
579
# File 'lib/tina4/messenger.rb', line 577

def test_connection
  { success: true, message: "DevMailbox mode — no SMTP connection needed" }
end

#unreadObject



583
# File 'lib/tina4/messenger.rb', line 583

def unread(...)    = @mailbox.unread_count