Sha256: 727820a2f45745f78fcc457bdf73a52cb56c8bb30ad1696ed8a23460cd20c9cc

Contents?: true

Size: 696 Bytes

Versions: 3

Compression:

Stored size: 696 Bytes

Contents

module EnsureIt
  module Config
    ERRORS = %i(smart standard)

    def self.errors(value = nil)
      value.nil? ? @errors ||= ERRORS.first : self.errors = value
    end

    def self.errors=(value)
      value = value.to_sym if value.is_a?(String)
      @errors = ERRORS.include?(value) ? value : ERRORS.first
    end

    def self.error_class(value = nil)
      value.nil? ? @error_class ||= EnsureIt::Error : self.error_class = value
    end

    def self.error_class=(value)
      return unless value.is_a?(Class) && value <= Exception
      @error_class = value
    end
  end

  def self.config
    Config
  end

  def self.configure
    yield(Config) if block_given?
    Config
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ensure_it-1.0.0 lib/ensure_it/config.rb
ensure_it-0.1.5 lib/ensure_it/config.rb
ensure_it-0.1.4 lib/ensure_it/config.rb