Sha256: 34a0ceae556c20be145ffc92d0e268d51a5153686ed3dc7771e270b74bddca33

Contents?: true

Size: 830 Bytes

Versions: 3

Compression:

Stored size: 830 Bytes

Contents

module Access
  class << self
    attr_accessor :config
  end

  def self.config
    @config && @config.access_token ? @config : @config = Config.new
  end

  # Set options via block
  def self.configure
    yield(config) if block_given?
  end

  class Config
    attr_accessor :access_token, :format, :api_environment, :api_version, :hashify

    def initialize
      @access_token = ENV['ACCESS_TOKEN']
      @format = ENV['ACCESS_FORMAT'] || 'json'
      @api_environment = ENV['ACCESS_ENVIRONMENT'] || 'staging'
      @api_version = ENV['ACCESS_VERSION'] || 'v1'
      @hashify = ENV['ACCESS_HASHIFY'] || 'false'
    end

    def reset
      self.access_token = ENV['ACCESS_TOKEN']
      self.format  = 'json'
      self.api_environment = 'staging'
      self.api_version = 'v1'
      self.hashify = false
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
access-1.1.2 lib/access/config.rb
access-1.1.1 lib/access/config.rb
access-1.1.0 lib/access/config.rb