Sha256: 3592818fd25439af93b7c14a233ff2e6e4097b9b3b2ba299b91e42ebf7e5998d

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 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
    DOMAINS = {'production' => '', 'demo' => '-demo', 'stage' => '-stage', 'staging' => '-stage' }
    attr_accessor :access_token, :format, :api_environment, :api_version, :hashify

    def initialize
      @access_token = ENV['ACCESS_TOKEN']
      @format = ENV['ACCESS_FORMAT'] || 'json'
      # demo, stage, production
      @api_environment = ENV['ACCESS_ENVIRONMENT'] || 'demo'
      @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 = 'demo'
      self.api_version = 'v1'
      self.hashify = false
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
access-1.1.7 lib/access/config.rb
access-1.1.6 lib/access/config.rb
access-1.1.5 lib/access/config.rb
access-1.1.4 lib/access/config.rb
access-1.1.3 lib/access/config.rb