Module: Fetcher

Defined in:
lib/fetcher.rb,
lib/fetcher/pop.rb,
lib/fetcher/base.rb,
lib/fetcher/imap.rb

Defined Under Namespace

Classes: Base, Imap, Pop

Class Method Summary collapse

Class Method Details

.create(options = {}) ⇒ Object

Use factory-style initialization or insantiate directly from a subclass

Options:

  • :type - Name of class as a symbol to instantiate

Other options are the same as Fetcher::Base.new

Example:

Fetcher.create(:type => :pop) is equivalent to Fetcher::Pop.new()

Raises:

  • (ArgumentError)


13
14
15
16
17
18
# File 'lib/fetcher.rb', line 13

def self.create(options={})
  options = options.dup
  klass = options.delete(:type)
  raise ArgumentError, 'Must supply a type' unless klass
  module_eval "#{klass.to_s.capitalize}.new(options)"
end