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.



672
673
674
675
676
# File 'lib/tina4/messenger.rb', line 672

def initialize(mailbox, **options)
  @mailbox = mailbox
  @from_address = options[:from_address] || ENV["TINA4_MAIL_FROM"] || "dev@localhost"
  @from_name    = options[:from_name]    || ENV["TINA4_MAIL_FROM_NAME"] || "Dev Mailer"
end

Instance Attribute Details

#mailboxObject (readonly)

Returns the value of attribute mailbox.



670
671
672
# File 'lib/tina4/messenger.rb', line 670

def mailbox
  @mailbox
end

Instance Method Details

#foldersObject



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

def folders        = ["inbox", "outbox"]

#inbox(**args) ⇒ Object



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

def inbox(**args)  = @mailbox.inbox(**args)

#readObject



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

def read(...)      = @mailbox.read(...)

#search(**args) ⇒ Object



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

def search(**args) = @mailbox.inbox(**args)

#send(to:, subject:, body:, html: false, cc: [], bcc: [], reply_to: nil, attachments: [], headers: {}) ⇒ Object



678
679
680
681
682
683
684
685
686
# File 'lib/tina4/messenger.rb', line 678

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



688
689
690
# File 'lib/tina4/messenger.rb', line 688

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

#unreadObject



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

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