Module: Mongoid::Warnings Private

Defined in:
lib/mongoid/warnings.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Encapsulates behavior around logging and caching warnings so they are only logged once.

Class Method Summary collapse

Class Method Details

.warning(id, message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define a warning message method for the given id.

Parameters:

  • id (Symbol)

    The warning identifier.

  • message (String)

    The warning message.



20
21
22
23
24
25
26
27
28
29
# File 'lib/mongoid/warnings.rb', line 20

def warning(id, message)
  singleton_class.class_eval do
    define_method("warn_#{id}") do
      unless instance_variable_get("@#{id}")
        Mongoid.logger.warn(message)
        instance_variable_set("@#{id}", true)
      end
    end
  end
end