Sha256: a310935e968df86d897e0e8094acf025d1cf49bd92a71ed97300052b801b7c85

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

require 'faraday'
require 'ivapi/version'

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

    def self.keys
      @keys ||= %i[
        api_endpoint
        username
        middleware
        password
        user_agent
        connection_options
        server_id
        hosting_id
      ]
    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 setup reset!

    private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ivapi-1.5.0 lib/ivapi/configuration.rb
ivapi-1.4.0 lib/ivapi/configuration.rb