Class: FastMailer::FileBlacklist

Inherits:
Object
  • Object
show all
Defined in:
lib/fast-mailer/file_blacklist.rb

Overview

Simplistic blacklist implementation. Reads a text file with a single email address per line into memory. Addresses found are considered blacklisted.

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ FileBlacklist

Returns a new instance of FileBlacklist.



9
10
11
12
13
14
15
16
17
# File 'lib/fast-mailer/file_blacklist.rb', line 9

def initialize(filename)
  @blacklist = []
  
  File.open(filename, 'r:utf-8') do |file|
    while line = file.gets
      @blacklist << line.strip
    end
  end
end

Instance Method Details

#blacklisted?(email) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fast-mailer/file_blacklist.rb', line 19

def blacklisted?(email)
  @blacklist.include?(email)
end