Module: Loader
- Defined in:
- lib/modules/loader.rb
Defined Under Namespace
Modules: Api
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.delete(id) ⇒ Object
56 57 58 59 |
# File 'lib/modules/loader.rb', line 56 def self.delete(id) filepath, exists = resolve_callsite(id) @cache.delete(exists ? filepath : id) end |
.export(value) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/modules/loader.rb', line 20 def self.export(value) callsite = Callsite.resolve if @cache.include?(callsite) && value.class == Hash # Special handling to enable multiple exports @cache[callsite] = @cache[callsite].merge(value) else @cache[callsite] = value end end |
.import(id, type = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/modules/loader.rb', line 30 def self.import(id, type=nil) if type == 'interop' return Interop.import(id, save_the_environment: @save_the_environment) end filepath, exists, parent = resolve_callsite(id) if type == 'internal' && !exists raise "Could not resolve local module at #{path}" end if exists # Prefer loading local module since we found it. begin Kernel.load(filepath, true) unless @cache.include?(filepath) rescue => e raise LoadError, "Could not load #{filepath} from #{parent}: #{e}" end return @cache[filepath] end # Failover to external load. return Interop.import(id, save_the_environment: @save_the_environment) end |