Sha256: 1cd0b0266124835584836b2b4307f9b1d690b33d3eebaaa2218de3ca155359f9

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 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

    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'
    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'
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
access-2.0.20 lib/access/config.rb
access-2.0.19 lib/access/config.rb
access-2.0.18 lib/access/config.rb
access-2.0.17 lib/access/config.rb
access-2.0.15 lib/access/config.rb
access-2.0.14 lib/access/config.rb
access-2.0.13 lib/access/config.rb
access-2.0.11 lib/access/config.rb
access-2.0.10 lib/access/config.rb
access-2.0.9 lib/access/config.rb
access-2.0.8 lib/access/config.rb
access-2.0.7 lib/access/config.rb
access-2.0.5 lib/access/config.rb
access-2.0.4 lib/access/config.rb
access-2.0.3 lib/access/config.rb
access-2.0.2 lib/access/config.rb
access-2.0.1 lib/access/config.rb
access-2.0.0 lib/access/config.rb