Class: Object

Inherits:
BasicObject
Defined in:
lib/modules.rb

Instance Method Summary collapse

Instance Method Details

#exportObject



94
95
96
97
98
# File 'lib/modules.rb', line 94

def export
  cache = Modules.instance_variable_get :@cache
  path = Modules.instance_variable_get :@path
  cache[path] = yield
end

#import(name) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/modules.rb', line 100

def import(name)
    if name[0] == '.'
      # Treat as local module.
      dirname = Modules.instance_variable_get :@dirname
      child_path = File.join dirname, name[1..-1]
      child_dirname = File.dirname child_path
      child_basename = File.basename child_path
      Modules.internal_import child_dirname, child_basename
    else
      # Treat as external ruby import.
      Modules.external_import name
    end
end