Class: Mailboxer::RecipientFilter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mailable, recipients) ⇒ RecipientFilter

Returns a new instance of RecipientFilter.



4
5
6
# File 'lib/mailboxer/recipient_filter.rb', line 4

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

Instance Attribute Details

#mailableObject (readonly)

Returns the value of attribute mailable.



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

def mailable
  @mailable
end

#recipientsObject (readonly)

Returns the value of attribute recipients.



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

def recipients
  @recipients
end

Instance Method Details

#callObject

recipients can be filtered on a conversation basis



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

def call
  return recipients unless mailable.respond_to?(:conversation)

  recipients.each_with_object([]) do |recipient, array|
    array << recipient if mailable.conversation.has_subscriber?(recipient)
  end
end