Class: Syntropy::ModuleLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/syntropy/module.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ ModuleLoader

Returns a new instance of ModuleLoader.



7
8
9
10
11
12
# File 'lib/syntropy/module.rb', line 7

def initialize(env)
  @root_dir = env[:root_dir]
  @env = env
  @loaded = {} # maps ref to code
  @fn_map = {} # maps filename to ref
end

Instance Method Details

#invalidate(fn) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/syntropy/module.rb', line 18

def invalidate(fn)
  ref = @fn_map[fn]
  return if !ref

  @loaded.delete(ref)
  @fn_map.delete(fn)
end

#load(ref) ⇒ Object



14
15
16
# File 'lib/syntropy/module.rb', line 14

def load(ref)
  @loaded[ref] ||= load_module(ref)
end