Module: Import_Module::API

Defined in:
lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb

Instance Method Summary collapse

Instance Method Details

#adopt_module(mod) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 71

def adopt_module(mod)
  sw = Thread.critical or Thread.critical = true # this 'or' is safe
  unless scope = (@__IMPORT_MODULE_PREFIX_scopes ||= {})[mod.id]
	scope = Scope.create(self, mod)
	@__IMPORT_MODULE_PREFIX_scopes[mod.id] = scope
  end
  scope.push
  Thread.critical = sw
  scope
end

#import_module(mod) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 60

def import_module(mod)
  scope = adopt_module(mod) #not upper compatible
  if block_given?
	begin
	  yield
	ensure
	  scope.pop
	end
  end
end

#set_orig_method(meth, orig) ⇒ Object



82
83
84
85
86
87
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 82

def set_orig_method(meth, orig)
  meth = meth.id2name if meth.is_a? Symbol
  orig = orig.id2name if orig.is_a? Symbol
  meth0 = Import_Module.name(orig, :orig)
  module_eval "def #{meth}(*a, &b); #{meth0}(*a, &b); end\n"
end