Class: Mailboxer::MailDispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/mailboxer/mail_dispatcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mailable, receipts) ⇒ MailDispatcher

Returns a new instance of MailDispatcher.



5
6
7
# File 'lib/mailboxer/mail_dispatcher.rb', line 5

def initialize(mailable, receipts)
  @mailable, @receipts = mailable, receipts
end

Instance Attribute Details

#mailableObject (readonly)

Returns the value of attribute mailable.



3
4
5
# File 'lib/mailboxer/mail_dispatcher.rb', line 3

def mailable
  @mailable
end

#receiptsObject (readonly)

Returns the value of attribute receipts.



3
4
5
# File 'lib/mailboxer/mail_dispatcher.rb', line 3

def receipts
  @receipts
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
# File 'lib/mailboxer/mail_dispatcher.rb', line 9

def call
  return false unless Mailboxer.uses_emails

  receipts.map do |receipt|
    email_to = receipt.receiver.send(Mailboxer.email_method, mailable)
    send_email(receipt) if email_to.present?
  end
end