Sha256: d8df8ea1806d91e842855d0bba638485ff691d24f23c2ae02cc91da19f7b4170

Contents?: true

Size: 777 Bytes

Versions: 8

Compression:

Stored size: 777 Bytes

Contents

module Tessa
  class Config
    include Virtus.model

    DEFAULT_STRATEGY = "default"

    attribute :username, String, default: -> (*_) { ENV['TESSA_USERNAME'] }
    attribute :password, String, default: -> (*_) { ENV['TESSA_PASSWORD'] }
    attribute :url, String, default: -> (*_) { ENV['TESSA_URL'] }
    attribute :strategy, String, default: -> (*_) { ENV['TESSA_STRATEGY'] || DEFAULT_STRATEGY }

    def connection
      @connection ||= Faraday.new(url: url) do |conn|
        if conn.respond_to?(:basic_auth)
          conn.basic_auth username, password
        else # Faraday >= 1.0
          conn.request :authorization, :basic, username, password
        end
        conn.request :url_encoded
        conn.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tessa-1.2.3 lib/tessa/config.rb
tessa-1.2.2 lib/tessa/config.rb
tessa-1.2.1 lib/tessa/config.rb
tessa-1.1.1 lib/tessa/config.rb
tessa-1.1.0 lib/tessa/config.rb
tessa-1.0.2 lib/tessa/config.rb
tessa-1.0.1 lib/tessa/config.rb
tessa-1.0.0 lib/tessa/config.rb