lib/rtm/javatmapi/superiseable.rb in rtm-javatmapi-0.2.0 vs lib/rtm/javatmapi/superiseable.rb in rtm-javatmapi-0.2.1

- old
+ new

@@ -1,10 +1,10 @@ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module Superiseable - + def superised @superised = true end def method_added(method_name) @@ -13,62 +13,19 @@ end @superised = false end def superising method_name - @to_superize ||= [] - @to_superize << method_name + @superized_methods ||= [] + @superized_methods << method_name end - def superize - @to_superize.each do |method_name| - self::JavaImplementations[self].each do |c| - # puts "Superising #{method_name} in #{self} (#{c})" - c.class_eval do - define_method(method_name) { |*args| super *args} - end + def register_java_implementation(klass) + self.included(klass) if self.respond_to?(:included) + return unless @superized_methods + @superized_methods.each do |method_name| + klass.class_eval do + define_method(method_name) { |*args| super *args} end end end - - -# def superising method_name -# start = Time.now -# -# puts self -# puts self::JavaImplementations[self] -# -# todo = self -# -## # TODO docu -## if todo == RTM::Scoped -## todo = [Java::OrgTmapiCore::Name, Java::OrgTmapiCore::Occurrence, Java::OrgTmapiCore::Association, Java::OrgTmapiCore::Variant] -## elsif todo == RTM::Reifiable -## todo = [Java::OrgTmapiCore::Association, Java::OrgTmapiCore::Name, Java::OrgTmapiCore::Occurrence, Java::OrgTmapiCore::Role, Java::OrgTmapiCore::TopicMap, Java::OrgTmapiCore::Variant] -## elsif todo == RTM::Construct -## todo = [Java::OrgTmapiCore::Association, Java::OrgTmapiCore::Name, Java::OrgTmapiCore::Occurrence, Java::OrgTmapiCore::Role, Java::OrgTmapiCore::TopicMap, Java::OrgTmapiCore::Variant, Java::OrgTmapiCore::Topic] -## elsif todo == RTM::Typed -## todo = [Java::OrgTmapiCore::Association, Java::OrgTmapiCore::Name, Java::OrgTmapiCore::Occurrence, Java::OrgTmapiCore::Role] -## end -# todo = [todo].flatten -# -# -# implFinder = ::ImplementationsForInterface.new -# if $CLASSPATH -# $CLASSPATH.to_a.each do |entry| -# entry.slice!(/^file:/) -# implFinder.addPathEntry(entry) -# end -# end -# -# todo.each do |i| -# IMPLEMENTATIONS[i.java_class] ||= implFinder.classInformationsFor(i.java_class).select {|c| !c.getClassName.include? "$" }.map {|c| eval(c.getClassName) } -# IMPLEMENTATIONS[i.java_class].each do |c| -# c.class_eval do -# define_method(method_name) { |*args| super *args} -# end -# end -# end -# #puts "Und so lange hat es gedauert:" + (Time.now - start).to_s -# end - end