Phrogz
12/14/2007 12:48:00 AM
On Dec 13, 3:38 pm, Paul <pdavi...@gmail.com> wrote:
> Let's say I have the following module:
>
> ------------------------
> module Parenting
>
> def add_child(a_child)
> self.children.push(a_child)
> end
>
> def delete_child(a_child)
> self.children.delete(a_child)
> end
>
> def children
> # need to implement
> end
>
> end
> ------------------------
>
> Is there a way to enforce that the 'children' method is implemented in
> any class which includes this module? Or do I simply rely on a
> commenting convention, as above?
module Parenting
def children
raise "OOPS!" #Better error message here
end
end
If a class defines that method, it will shadow the module method. As
long as the class method doesn't try to call super, you should be good
to go.