Sha256: be86f735a7a9eb4b1e28528296383778fce80410d5a0b285bda80dd15f792fe9

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 Bytes

Contents

module Fetcher
  # Use factory-style initialization or insantiate directly from a subclass
  #
  # Options:
  # * <tt>:type</tt> - 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()
  def self.create(options={})
    klass = options.delete(:type)
    raise ArgumentError, 'Must supply a type' unless klass
    module_eval "#{klass.to_s.capitalize}.new(options)"
  end
end

require 'fetcher/base'
require 'fetcher/imap'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
things-fetcher-0.1.3 lib/fetcher.rb
things-fetcher-0.1.2 lib/fetcher.rb
things-fetcher-0.1.1 lib/fetcher.rb