Sha256: 89457256cbb6d669fccd3bcafb7a598d5dae9f44bdaf5aa16220b7af42084ed2

Contents?: true

Size: 680 Bytes

Versions: 4

Compression:

Stored size: 680 Bytes

Contents

module Outliers
  class Provider

    attr_reader :credentials

    def self.connect_to(credentials)
      provider = credentials.fetch 'provider'
      Outliers::Providers.name_map.fetch(provider).new credentials
    rescue KeyError
      raise Outliers::Exceptions::UnknownProvider.new "Unkown provider '#{provider.join('_').downcase}'."
    end

    def self.to_human
      (self.to_s.split('::') - ['Outliers', 'Providers']).map { |p| p.underscore }.join('_').downcase
    end

    def initialize(credentials)
      @credentials = credentials
      @logger      = Outliers.logger
      settings credentials.keys_to_sym
    end

    def logger
      @logger
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
outliers-0.3.3 lib/outliers/provider.rb
outliers-0.3.2 lib/outliers/provider.rb
outliers-0.3.1 lib/outliers/provider.rb
outliers-0.3.0 lib/outliers/provider.rb