Sha256: 3649186194e8d69dab72169a0cf4b9b11555d21365e36a9be9cd36d1bce92a93

Contents?: true

Size: 896 Bytes

Versions: 6

Compression:

Stored size: 896 Bytes

Contents

require 'faraday'
require 'ivapi/version'

module Ivapi
  module Configuration
    attr_accessor :server_id, :user_agent, :connection_options,
                  :web_endpoint, :api_endpoint, :username, :password

    def self.keys
      @keys ||= [
        :api_endpoint,
        :server_id,
        :username,
        :middleware,
        :password,
        :user_agent,
        :connection_options
      ]
    end

    def configure
      yield self
      true
    end

    # Reset configuration options to default values
    def reset!
      Ivapi::Configuration.keys.each do |key|
        instance_variable_set(:"@#{key}", Ivapi::Default.options[key])
      end
      self
    end
    alias_method :setup, :reset!

    private

    def options
      Hash[
        Ivapi::Configuration.keys.map do |key|
          [key, instance_variable_get(:"@#{key}")]
        end
      ]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ivapi-1.1.8 lib/ivapi/configuration.rb
ivapi-1.1.7 lib/ivapi/configuration.rb
ivapi-1.1.6 lib/ivapi/configuration.rb
ivapi-1.1.5 lib/ivapi/configuration.rb
ivapi-1.1.4 lib/ivapi/configuration.rb
ivapi-1.1.3 lib/ivapi/configuration.rb