Class: Mailboxer::MailDispatcher
- Inherits:
-
Object
- Object
- Mailboxer::MailDispatcher
- Defined in:
- lib/mailboxer/mail_dispatcher.rb
Instance Attribute Summary collapse
-
#mailable ⇒ Object
readonly
Returns the value of attribute mailable.
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(mailable, recipients) ⇒ MailDispatcher
constructor
A new instance of MailDispatcher.
Constructor Details
#initialize(mailable, recipients) ⇒ MailDispatcher
Returns a new instance of MailDispatcher.
6 7 8 |
# File 'lib/mailboxer/mail_dispatcher.rb', line 6 def initialize(mailable, recipients) @mailable, @recipients = mailable, recipients end |
Instance Attribute Details
#mailable ⇒ Object (readonly)
Returns the value of attribute mailable.
4 5 6 |
# File 'lib/mailboxer/mail_dispatcher.rb', line 4 def mailable @mailable end |
#recipients ⇒ Object (readonly)
Returns the value of attribute recipients.
4 5 6 |
# File 'lib/mailboxer/mail_dispatcher.rb', line 4 def recipients @recipients end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mailboxer/mail_dispatcher.rb', line 10 def call return false unless Mailboxer.uses_emails if Mailboxer.mailer_wants_array send_email(filtered_recipients) else filtered_recipients.each do |recipient| email_to = recipient.send(Mailboxer.email_method, mailable) send_email(recipient) if email_to.present? end end end |