Sha256: c320afcb43c94af4cbe1810831f67f59cc48de4280704998ad0a29a133544758

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

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, :api_environment, :return_json, :hashify, :access_timeout

    def initialize
      @access_token = ENV['ACCESS_TOKEN']
      # demo, stage, production
      @api_environment = ENV['ACCESS_ENVIRONMENT'] || 'demo'
      # @api_version = ENV['ACCESS_VERSION'] || 'v1'
      @return_json = ENV['ACCESS_RETURN_JSON'] || 'false'
      # only used when return_json is true
      @hashify = ENV['ACCESS_HASHIFY'] || 'false'
      # how many seconds till we raise a Access::Error::Timeout
      @access_timeout = ENV['ACCESS_TIMEOUT'] || '10'
    end

    def reset
      self.access_token = ENV['ACCESS_TOKEN']
      self.api_environment = ENV['ACCESS_ENVIRONMENT'] || 'demo'
      # self.api_version = 'v1'
      self.return_json = ENV['ACCESS_RETURN_JSON'] || 'false'
      self.hashify = ENV['ACCESS_HASHIFY'] || 'false'
      self.access_timeout = ENV['ACCESS_TIMEOUT'] || '10'
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
access-2.0.30 lib/access/config.rb
access-2.0.29 lib/access/config.rb
access-2.0.28 lib/access/config.rb
access-2.0.27 lib/access/config.rb
access-2.0.26 lib/access/config.rb
access-2.0.25 lib/access/config.rb
access-2.0.24 lib/access/config.rb
access-2.0.23 lib/access/config.rb
access-2.0.22 lib/access/config.rb
access-2.0.21 lib/access/config.rb