Sha256: 6743c88d8805ed8745f42650c97904ced0882ed2250875e6ce3fe6df453a7c2b

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 Bytes

Contents

module Securetrading
  class ConfigurationError < StandardError; end
  class Configuration
    attr_accessor :user, :password
    attr_writer :site_reference, :auth_method, :site_security_password

    def site_security_password
      return @site_security_password if @site_security_password.present?
      fail ConfigurationError, 'You are trying to use site security '\
        'but your password is empty. Please check gem configuration.'
    end

    def auth_method
      @auth_method ||= 'FINAL'.freeze
    end

    def site_reference
      return @site_reference if @site_reference.present?
      fail ConfigurationError, 'Site reference is required!'
    end

    def auth
      return @auth if @auth.present?
      if user.present? && password.present?
        @auth ||= Base64.encode64("#{user}:#{password}")
      else
        fail ConfigurationError, 'User and password or auth are required!'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
securetrading-0.3.2 lib/securetrading/configuration.rb
securetrading-0.3.1 lib/securetrading/configuration.rb
securetrading-0.3.0 lib/securetrading/configuration.rb