lib/lightio/module/base.rb in lightio-0.4.0.pre vs lib/lightio/module/base.rb in lightio-0.4.0
- old
+ new
@@ -1,7 +1,17 @@
module LightIO::Module
module Base
+ class << self
+ def find_library_class(klass)
+ return LightIO::Library::Base.send(:nameless_classes)[klass] if klass.name.nil?
+ name = klass.name
+ namespace_index = name.rindex("::")
+ class_name = namespace_index.nil? ? name : name[(namespace_index + 2)..-1]
+ LightIO::Library.const_get(class_name)
+ end
+ end
+
module NewHelper
protected
def define_new_for_modules(*mods)
mods.each {|mod| define_new_for_module(mod)}
end
@@ -26,15 +36,11 @@
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)
+ Base.find_library_class(self)
end
end
end
end
\ No newline at end of file