def filter_emails(emails)
      return if emails.blank?

      email_list = Array(emails).select do |recipient|
        recipient.to_s =~ @whitelist
      end

      email_list.length > 1 ? email_list : email_list.shift
    end
def filter_emails(emails)
      return if emails.blank?

      email_list = Array(emails).select do |recipient|
        recipient.to_s =~ @whitelist
      end

      email_list.length > 1 ? email_list : email_list.shift
    end
Private: Filter out any emails that match the whitelist regex.

 emails - List of emails to filter through.

 Examples

   Given [/hacking.com/] being the whitelist.

   filter_emails('me@garrettbjerkhoel.com')
   # => nil

   filter_emails(['me@garrettbjerkhoel.com', 'evil@hacking.com'])
   # => 'garrett@github.com'

   filter_emails(['matt@github.com', 'garrett@github.com'])
   # => ['matt@github.com', 'garrett@github.com']

 Returns array of emails if the list is greater than one, if only one item
 return just that single email, if empty, return nil to reset the field.