Sha256: 2eccac44fe1383cd3564b712eec0fd6ba9491541f9abb22f994d8780aa259dcd

Contents?: true

Size: 829 Bytes

Versions: 9

Compression:

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

9 entries across 9 versions & 1 rubygems

Version Path
access-1.0.8 lib/access/config.rb
access-1.0.7 lib/access/config.rb
access-1.0.6 lib/access/config.rb
access-1.0.5 lib/access/config.rb
access-1.0.4 lib/access/config.rb
access-1.0.3 lib/access/config.rb
access-1.0.2 lib/access/config.rb
access-1.0.1 lib/access/config.rb
access-1.0.0 lib/access/config.rb