Sha256: b4b60d743af0cf79eb889e4a7679c1f4c9aacb7f4805d29cfad62407241df490

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

module Dexcom
  class Configuration
    attr_accessor :username, :password, :outside_usa, :logger, :log_level

    DEFAULT_LOGGER = nil
    DEFAULT_LOGGER_LEVEL = :info

    def initialize
      @username = nil
      @password = nil
      @outside_usa = nil
      @logger = DEFAULT_LOGGER
      @log_level = DEFAULT_LOGGER_LEVEL
    end

    def base_url
      outside_usa ? URL_BASE_OUTSIDE_USA : URL_BASE
    end
  end

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

    def configuration=(config)
      raise StandardError('Invalid configuration provided') unless config.is_a? Dexcom::Configuration

      @configuration = config
    end

    def configure
      yield configuration
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dexcom-0.3.1 lib/dexcom/configuration.rb