Class: Mail::TestRetriever

Inherits:
Object
  • Object
show all
Defined in:
lib/mail/network/retriever_methods/test_retriever.rb

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ TestRetriever

Returns a new instance of TestRetriever.



8
9
10
# File 'lib/mail/network/retriever_methods/test_retriever.rb', line 8

def initialize(values)
  @@emails = []
end

Instance Method Details

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



23
24
25
26
27
# File 'lib/mail/network/retriever_methods/test_retriever.rb', line 23

def all(options = {}, &block)
  options ||= {}
  options[:count] = :all
  find(options, &block)
end

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



12
13
14
15
16
17
18
19
20
21
# File 'lib/mail/network/retriever_methods/test_retriever.rb', line 12

def find(options = {}, &block)
  emails = @@emails
  case count = options[:count]
    when :all then emails
    when 1 then emails.first
    when Fixnum then emails[0, count]
    else
      raise 'Invalid count option value'
  end
end