Module: RUtilAnts
- Defined in:
- lib/rUtilAnts/GUI.rb,
lib/rUtilAnts/Misc.rb,
lib/rUtilAnts/Archive.rb,
lib/rUtilAnts/Logging.rb,
lib/rUtilAnts/Plugins.rb,
lib/rUtilAnts/Platform.rb,
lib/rUtilAnts/URLCache.rb,
lib/rUtilAnts/MySQLPool.rb,
lib/rUtilAnts/URLAccess.rb,
lib/rUtilAnts/ForeignProcess.rb,
lib/rUtilAnts/SingletonProxy.rb,
lib/rUtilAnts/URLHandlers/FTP.rb,
lib/rUtilAnts/URLHandlers/HTTP.rb,
lib/rUtilAnts/GUI/BugReportDialog.rb,
lib/rUtilAnts/URLHandlers/DataImage.rb,
lib/rUtilAnts/URLHandlers/LocalFile.rb,
lib/rUtilAnts/Platforms/unix/PlatformInfo.rb,
lib/rUtilAnts/Platforms/linux/PlatformInfo.rb,
lib/rUtilAnts/Platforms/cygwin/PlatformInfo.rb,
lib/rUtilAnts/Platforms/macosx/PlatformInfo.rb,
lib/rUtilAnts/Platforms/windows/PlatformInfo.rb
Overview
WxRuby has to be loaded correctly in the environment before requiring this file
Defined Under Namespace
Modules: Archive, ForeignProcess, GUI, Logging, Misc, MySQLPool, Platform, Plugins, URLAccess, URLCache
Class Method Summary collapse
-
.make_singleton_proxy(iSrcModule, oDstModule) ⇒ Object
Make public methods from a module accessible in another module, using a singleton as proxy.
Class Method Details
.make_singleton_proxy(iSrcModule, oDstModule) ⇒ Object
Make public methods from a module accessible in another module, using a singleton as proxy
- Parameters
-
iSrcModule (Module): Module to get public methods from
-
oDstModule (Module): Module that will encapsulate the singleton and route all public methods through that singleton
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rUtilAnts/SingletonProxy.rb', line 8 def self.make_singleton_proxy(iSrcModule, oDstModule) lSrcModuleConstName = iSrcModule.name.gsub(/\W/,'_') # Create the singleton class if !oDstModule.const_defined?("SingletonClassForModule__#{lSrcModuleConstName}") lSingletonClass = oDstModule.const_set("SingletonClassForModule__#{lSrcModuleConstName}", Class.new) lSingletonClass.class_eval("include #{iSrcModule}") # Instantiate it in the module lSymSingletonVarName = "@@__SingletonForModule__#{lSrcModuleConstName}".to_sym oDstModule.send(:class_variable_set, lSymSingletonVarName, lSingletonClass.new) # Create public methods from iSrcModule to oDstModule, using the singleton as a proxy iSrcModule.instance_methods.map { |iMethodName| iMethodName.to_sym }.each do |iSymMethodName| oDstModule.send(:define_method, iSymMethodName) do |*iArgs, &iBlock| oDstModule.send(:class_variable_get, lSymSingletonVarName).send(iSymMethodName, *iArgs, &iBlock) end end end end |