def define_class(name, superclass = Object, &block) name = name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } superclass = superclass.to_s.gsub(/^:*/, "::") eval("class #{name} < #{superclass}; end") clazz = eval(name) clazz.unloadable if clazz.respond_to?(:unloadable) clazz.class_eval(&block) if block_given? clazz end