Sha256: d7e0fd626feebd2a41ae0484434ee498e52d1d234f21c4555de14881cdf801f2

Contents?: true

Size: 757 Bytes

Versions: 5

Compression:

Stored size: 757 Bytes

Contents

module Exchanger
  class Config
    include Singleton

    attr_accessor :endpoint, :timeout, :username, :password, :debug, :insecure_ssl

    def initialize
      reset
    end

    # Reset the configuration options to the defaults.
    def reset
      @endpoint = nil
      @timeout = 5
      @username = nil
      @password = nil
      @debug = false
      @insecure_ssl = false
    end

    # Configure Exchanger client from a hash. This is usually called after parsing a
    # yaml config file such as exchanger.yml.
    #
    # Example:
    #
    # <tt>Exchanger::Config.instance.from_hash({})</tt>
    def from_hash(settings)
      settings.each do |name, value|
        send("#{name}=", value) if respond_to?("#{name}=")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
exchanger-0.2.0 lib/exchanger/config.rb
exchanger-0.1.6 lib/exchanger/config.rb
exchanger-0.1.5 lib/exchanger/config.rb
exchanger-0.1.4 lib/exchanger/config.rb
exchanger-0.1.3 lib/exchanger/config.rb