Sha256: 8678098856d97efb0e68a4484a6307a655be9bee19b3a7271eb89774c5687ca0

Contents?: true

Size: 518 Bytes

Versions: 1

Compression:

Stored size: 518 Bytes

Contents

module Barchart
  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end

  def self.reset_configuration!
    @configuration = Configuration.new
  end

  class Configuration
    ATTRIBUTES = [:api_key, :api_base_url]
    attr_accessor *ATTRIBUTES

    def validate!
      raise "Invalid or missing configuration"  unless ATTRIBUTES.all? { |attribute| send(attribute).present? }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
barchart-0.0.1 lib/barchart/configuration.rb