Method: CoinSync::Source#initialize
- Defined in:
- lib/coinsync/source.rb
#initialize(config, key) ⇒ Source
Returns a new instance of Source.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/coinsync/source.rb', line 7 def initialize(config, key) @config = config @key = key definition = config.source_definitions[key] if definition.is_a?(Hash) @params = definition @filename = definition['file'] type = (definition['type'] || key).to_sym elsif definition.is_a?(String) @params = {} @filename = definition type = key.to_sym elsif !config.source_definitions.has_key?(key) raise "No such key in source list: '#{key}'" else raise "Unexpected source definition for '#{key}': #{definition}" end @importer_class = Importers.registered[type] if @importer_class.nil? if @params['type'] raise "Unknown source type for '#{key}': #{params['type']}" else raise "Unknown source type for '#{key}': please include a 'type' parameter " + "or use a name of an existing importer" end end end |