From: Yohanes Santoso Date: 2002-04-10T10:36:52+09:00 Subject: mix-in dependancy I'm playing around with the idea of attaching modules to some class at runtime. Suppose I have this module: module Sort def sort #depends on presence of self#<=> #do sorting end end that was selected at run time to be grafted into this object: class A #May or may not have #<=>. end by the eval and include mechanisms: eval "class A include Sort end" What I want is for the including to fail if A does not have #<=>. Is there a built-in mechanism to detect this or should I do this manually: module Sort #application module policy. #require all application modules to have #prereq. def prereq [:<=>] end def sort #depends on presence of self#<=> #do sorting end end class A #something end and the inclusion mechanism: begin Sort.prereq.each {|x| A.send x } eval "class A; include Sort; end" rescue raise "Unmet prerequisite." end YS.