Module: Fetcher
- Defined in:
- lib/fetcher.rb,
lib/fetcher/base.rb,
lib/fetcher/imap.rb
Defined Under Namespace
Class Method Summary collapse
-
.create(options = {}) ⇒ Object
Use factory-style initialization or insantiate directly from a subclass.
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()
13 14 15 16 17 |
# File 'lib/fetcher.rb', line 13 def self.create(={}) klass = .delete(:type) raise ArgumentError, 'Must supply a type' unless klass module_eval "#{klass.to_s.capitalize}.new(options)" end |