Class: MailProcessor::Processor

Inherits:
Base
  • Object
show all
Defined in:
lib/mail_processor/processor.rb

Instance Method Summary collapse

Methods inherited from Base

log, #log

Constructor Details

#initialize(options = {}, &block) ⇒ Processor

Returns a new instance of Processor.



7
8
9
10
11
12
13
# File 'lib/mail_processor/processor.rb', line 7

def initialize options = {}, &block
  @attributes = {
    :retriever => nil
  }
  instance_eval &block
  self
end

Instance Method Details

#process(options = {}, &block) ⇒ Object



28
29
30
# File 'lib/mail_processor/processor.rb', line 28

def process options = {}, &block
  @retriever.process &block
end

#retriever(method, options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/mail_processor/processor.rb', line 16

def retriever method, options = {}, &block
  @retriever = case method
               when :pop3 then
                 Pop3.new options, &block
               when :mail_dir then
                 MailDir.new options, &block
               else
                 raise UnkownRetrieverError, "Retriever type #{method.to_s} not known"
               end
end