Class: BounceFetcher::BounceFetcher

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

Instance Method Summary collapse

Constructor Details

#initialize(fetcher, extractor, detector) ⇒ BounceFetcher

Returns a new instance of BounceFetcher.



16
17
18
19
20
# File 'lib/bounce_fetcher.rb', line 16

def initialize(fetcher, extractor, detector)
  @fetcher = fetcher
  @extractor = extractor
  @detector = detector
end

Instance Method Details

#each(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bounce_fetcher.rb', line 22

def each(options = {})
  options = { :delete => true }.merge(options)

  @fetcher.each do |e|
    if @detector.permanent_bounce?(e)
      @extractor.extract_emails(e.body).each do |email|
        yield email
      end
      e.delete if options[:delete]
    end
  end
end