Module: TrackOpenInstances
- Defined in:
- lib/track_open_instances.rb,
lib/track_open_instances/version.rb
Overview
Mixin to track instances of a class that require explicit cleanup
This module provides a mechanism to track instances of classes that need to be explicitly closed or cleaned up. It maintains a list of all instances created and allows checking for any unclosed instances, which can help in identifying resource leaks.
Defined Under Namespace
Modules: ClassMethods Classes: OpenInstance
Constant Summary collapse
- VERSION =
The last released version of this gem
'0.1.11'
Class Method Summary collapse
-
.included(base)
private
Ruby hook executed when this module is included in a base class.
Class Method Details
.included(base)
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.
This method returns an undefined value.
Ruby hook executed when this module is included in a base class
Sets up the necessary class instance variables and extends the base class with ClassMethods.
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/track_open_instances.rb', line 91 def self.included(base) base.extend(ClassMethods) # @!attribute [rw] open_instances # Internal storage for all tracked instances # @return [Hash{Object => OpenInstance}] The list of currently tracked instances base.instance_variable_set(:@open_instances, {}.compare_by_identity) # @!visibility private # @!attribute [r] open_instances_mutex # Mutex to ensure thread-safe access to the open_instances hash base.instance_variable_set(:@open_instances_mutex, Thread::Mutex.new) end |