# = basefactory.rb require 'facets/core/module/class_extension' # BaseFactory module BaseFactory def self.included( base ) class << base alias :instance :new end end class_extension { # Factory-pattern initialization. def new(type, *set, &yld) #begin send(type, *set, &yld) #rescue # raise FactoryError, "Not a known #{self} -- #{type}." #end end # Subclasses should have standard #new methods. def inherited( subclass ) class << subclass alias :new :instance end end } end class FactoryError < ArgumentError end