Sha256: 0bd7fdab1c389ea62aa19b42e08f43bff6483fd8f4e83ec43b14f0c66f1618a5
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module LightIO::Module module Base module NewHelper protected def define_new_for_modules(*mods) mods.each {|mod| define_new_for_module(mod)} end def define_new_for_module(mod) LightIO::Module.send(:module_eval, <<-STR, __FILE__, __LINE__ + 1) module #{mod} module ClassMethods def new(*args, &blk) obj = LightIO::Library::#{mod}.__send__ :allocate obj.__send__ :initialize, *args, &blk obj end end end STR end end module Helper protected def wrap_to_library(obj) return _wrap(obj) if self.respond_to?(:_wrap) find_library_class._wrap(obj) end # private def find_library_class name = self.name namespace_index = name.rindex("::") class_name = namespace_index.nil? ? name : name[(namespace_index + 2)..-1] LightIO::Library.const_get(class_name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lightio-0.4.0.pre | lib/lightio/module/base.rb |