Module: WrapInModule

Defined in:
lib/wrap_in_module.rb,
lib/wrap_in_module/version.rb

Defined Under Namespace

Modules: LoadInModuleMethods Classes: MissingFile

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.wrap_file(_module, _file_path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wrap_in_module.rb', line 20

def self.wrap_file(_module, _file_path)
  _module.extend ::WrapInModule::LoadInModuleMethods
  _module.module_eval do
    # The file with which the Script was instantiated.
    attr_reader :__main_file

    # The directory in which main_file is located, and relative to which
    # #load searches for files before falling back to Kernel#load.
    attr_reader :__dir
    
    # A hash that maps <tt>filename=>true</tt> for each file that has been
    # required locally by the script. This has the same semantics as <tt>$"</tt>,
    # alias <tt>$LOADED_FEATURES</tt>, except that it is local to this script.
    attr_reader :__loaded_features

    @__main_file = File.expand_path(_file_path)
    @__dir = File.dirname(@__main_file)
    @__loaded_features = {}
    load_in_module(@__main_file)
  end
end