Module: Mongo::Deprecations Private
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.
Used for reporting deprecated behavior in the driver. When it is possible to detect that a deprecated feature is being used, a warning should be issued through this module.
The warning will be issued no more than once for that feature, regardless of how many times Mongo::Deprecations.warn is called.
Constant Summary collapse
- MUTEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mutex for synchronizing access to warned features.
Thread::Mutex.new
Constants included from Loggable
Instance Method Summary collapse
-
#clear! ⇒ Object
private
Clears all memory of previously warned features.
-
#warn(feature, message) ⇒ Object
private
Issue a warning about a deprecated feature.
-
#warned!(feature) ⇒ Object
private
Mark that a warning for a given deprecated feature has been issued.
-
#warned?(feature, prefix: false) ⇒ true | false
private
Check if a warning for a given deprecated feature has already been issued.
Methods included from Loggable
log_debug, log_error, log_fatal, log_info, log_warn, logger
Instance Method Details
#clear! ⇒ 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.
Clears all memory of previously warned features.
58 59 60 61 |
# File 'lib/mongo/deprecations.rb', line 58 def clear! MUTEX.synchronize { warned_features reset: true } nil end |
#warn(feature, 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.
Issue a warning about a deprecated feature. The warning is written to the logger, and will not be written more than once per feature.
30 31 32 33 34 35 36 37 |
# File 'lib/mongo/deprecations.rb', line 30 def warn(feature, ) MUTEX.synchronize do return if _warned?(feature) _warned!(feature) log_warn("[DEPRECATION:#{feature}] #{message}") end end |
#warned!(feature) ⇒ 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.
Mark that a warning for a given deprecated feature has been issued.
52 53 54 55 |
# File 'lib/mongo/deprecations.rb', line 52 def warned!(feature) MUTEX.synchronize { _warned!(feature) } nil end |
#warned?(feature, prefix: false) ⇒ true | false
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.
Check if a warning for a given deprecated feature has already been issued.
45 46 47 |
# File 'lib/mongo/deprecations.rb', line 45 def warned?(feature, prefix: false) MUTEX.synchronize { _warned?(feature, prefix: prefix) } end |