Class: Backports::StdLib::LoadedFeatures
- Defined in:
- lib/backports/tools/std_lib.rb
Constant Summary collapse
- @@our_loads =
Full paths are recorded in $LOADED_FEATURES.
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#include?(feature) ⇒ Boolean
Requested features are recorded in $LOADED_FEATURES.
Class Method Details
.mark_as_loaded(feature) ⇒ Object
20 21 22 23 |
# File 'lib/backports/tools/std_lib.rb', line 20 def self.mark_as_loaded(feature) @@our_loads[feature] = true # Nothing to do, the full path will be OK end |
Instance Method Details
#include?(feature) ⇒ Boolean
Requested features are recorded in $LOADED_FEATURES
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/backports/tools/std_lib.rb', line 8 def include?(feature) return true if @@our_loads[feature] # Assume backported features are Ruby libraries (i.e. not C) @loaded ||= $LOADED_FEATURES.group_by{|p| File.basename(p, ".rb")} if fullpaths = @loaded[File.basename(feature, ".rb")] fullpaths.any?{|fullpath| base_dir, = fullpath.partition("/#{feature}") $LOAD_PATH.include?(base_dir) } end end |