Module: Datadog::Tracing::Contrib::Support
- Defined in:
- lib/datadog/tracing/contrib/support.rb
Overview
Miscellaneous support methods to aid in the creation of integrations.
Class Method Summary collapse
-
.fully_loaded?(base_module, constant) ⇒ Boolean
Checks if a constant is loaded in a module, handling autoloaded constants correctly.
Class Method Details
.fully_loaded?(base_module, constant) ⇒ Boolean
Checks if a constant is loaded in a module, handling autoloaded constants correctly.
This method is particularly useful when you need to check if a constant is fully loaded, not just defined. It handles the special case of autoloaded constants, which return non-nil for ‘defined?` even when they haven’t been loaded yet.
19 20 21 22 23 24 |
# File 'lib/datadog/tracing/contrib/support.rb', line 19 def fully_loaded?(base_module, constant) # Autoload constants return `constant` for `defined?`, but that doesn't mean they are loaded... base_module.const_defined?(constant) && # ... to check that we need to call `autoload?`. If it returns `nil`, it's loaded. base_module.autoload?(constant).nil? end |