Module: Mongoid::Warnings Private

Defined in:
build/mongoid-master/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.



12
13
14
15
16
17
18
19
20
21
# File 'build/mongoid-master/lib/mongoid/warnings.rb', line 12

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