Sha256: 3b26c45acce12d98b3c8598b4a58738532a9890ca9ee6872d9bd2660a94c03b9

Contents?: true

Size: 926 Bytes

Versions: 4

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

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

4 entries across 4 versions & 1 rubygems

Version Path
ivapi-1.8.0 lib/ivapi/configuration.rb
ivapi-1.7.0 lib/ivapi/configuration.rb
ivapi-1.6.1 lib/ivapi/configuration.rb
ivapi-1.6.0 lib/ivapi/configuration.rb