class PrototypeClass attr_reader :prototype def initialize (prototype) @prototype = prototype end def new (*definitions) new_class = Class.new(self.class) # With a modern Ruby you could use caller to find the # file and line, then pass it in to give better error reporting. for definition in definitions new_class.module_eval definition end return new_class.new(self) end def def (definition) # With a modern Ruby you could use caller to find the # file and line, then pass it in to give better error reporting. self.class.module_eval "def #{definition} end" end def include (*mod) self.class.module_eval "include #{mod,join ', '}" end end Prototype = PrototypeClass.new(nil)