Sha256: 5b7075b5b571111685d93106e0d12c235a1bb963e1028e847fe46a2ff689faaf

Contents?: true

Size: 768 Bytes

Versions: 1

Compression:

Stored size: 768 Bytes

Contents

module Duracloud
  class Configuration
    class << self
      attr_accessor :host, :port, :user, :password
    end

    attr_reader :host, :port, :user, :password

    def initialize(host: nil, port: nil, user: nil, password: nil)
      @host     = host     || default(:host)
      @port     = port     || default(:port)
      @user     = user     || default(:user)
      @password = password || default(:password)
      freeze
    end

    def base_url
      URI::HTTPS.build(host: host, port: port)
    end

    private

    def default(attr)
      self.class.send(attr) || ENV["DURACLOUD_#{attr.to_s.upcase}"]
    end

    def inspect
      "#<#{self.class} host=#{host.inspect}, port=#{port.inspect}, user=#{user.inspect}, password=\"******\">"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duracloud-client-0.0.1 lib/duracloud/configuration.rb