Sha256: 82edeafdd107167eb8f4b2854067ed708a2b026769c842c2bf9844c0ed85fdff

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

require 'truemail/version'
require 'truemail/core'
require 'truemail/configuration'
require 'truemail/validator'

module Truemail
  INCOMPLETE_CONFIG = 'verifier_email is required parameter'.freeze
  NOT_CONFIGURED = 'use Truemail.configure before'.freeze

  class << self
    def configuration
      @configuration ||= begin
        return unless block_given?
        configuration = Truemail::Configuration.new
        yield(configuration)
        raise ConfigurationError, INCOMPLETE_CONFIG unless configuration.complete?
        configuration
      end
    end

    def configure(&block)
      configuration(&block)
    end

    def reset_configuration!
      @configuration = nil
    end

    def validate(email, **options)
      raise ConfigurationError, NOT_CONFIGURED unless configuration
      Truemail::Validator.new(email, **options).run
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
truemail-0.1.1.2 lib/truemail.rb
truemail-0.1.1 lib/truemail.rb
truemail-0.1.0 lib/truemail.rb