# Declaration for module methods which need to be implemented

**URL:** <https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/196543>\
**Category:** Ruby\
**Created:** [December 13, 2007, 11:47pm UTC](https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/196543 "2007-12-13T23:47:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [December 13, 2007, 11:47pm UTC](https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/196543/1 "2007-12-13T23:47:10Z")

</div>

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  
but is there a programtaic way to declare this?  
end

## end

Is there a way to enforce that the ‘children’ method is understood in  
any class which includes this module? Or do I simply rely on a  
comment, as above

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [December 14, 2007, 11:18am UTC](https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/196543/2 "2007-12-14T11:18:41Z")

</div>

On Dec 13, 2007 11:30 PM, Paul [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Let’s say I have the following module:  
> […]  
> Is there a way to enforce that the ‘children’ method is understood in  
> any class which includes this module? Or do I simply rely on a  
> comment, as above

There are ways (you can play around with Parenting.inherited and do  
method rewrites), yet I suspect you’re better off with a comment. All  
methods for ensuring this have limitations that will block some cases  
of valid code (though that may be resolved by adding a sort of  
say-that-it-is-OK method).

Eivind.
