class Module < Object
TODO: Is there any way to do this but still allow 'include' to occur at the top of the class definition?
TODO: One way to do this is to disallow instantiation of the object unless the specific methods are defined. This is how C++ does it; the advantage is that virtual functions in the base class can be implemented in anywhere in the hierarchy. A way around this for now is to declare a "stub" in the base class for any mixins that use mixin_requires, though this has its own set of problems.
TODO: It would be nice if we could optionally check for arity of the methods.
module Foo mixin_requires :foo, :bar
def xyz # If foo and bar are not defined in the derived class, then this will # raise an exception, so it's best to know that this won't work at # load-time. foo bar end end
class Bar def foo puts "foo" end
def bar puts "bar" end
# This must come last, because foo and bar must be defined before # including Foo. If they are not defined, then an exception will be # thrown. include Foo end
Require that the class/module that a mixin is being included in MUST define certain methods.
|methods||symbols representing the methods that MUST be defined.|