Sha256: b8b97d337486e2e33625c61f69256961982b0257b29ea70baba4feb8d0cfc540

Contents?: true

Size: 613 Bytes

Versions: 3

Compression:

Stored size: 613 Bytes

Contents

require "sms_manager/error/configuration_error"

module SmsManager
  module Configurable
    attr_writer :username, :hashed_password

    def configure
      yield self
      validate_credential_type!
      self
    end

    private

    def credentials
      {
        :username    => @username,
        :hashed_password => @hashed_password,
      }
    end

    def validate_credential_type!
      credentials.each do |credential, value|
        unless value.is_a?(String)
          raise ConfigurationError, "Invalid #{credential} specified: #{value} must be a string."
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sms_manager-0.1.2 lib/sms_manager/configurable.rb
sms_manager-0.1.1 lib/sms_manager/configurable.rb
sms_manager-0.1.0 lib/sms_manager/configurable.rb