# 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/123095>\
**Category:** Ruby\
**Created:** [December 13, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/123095 "2007-12-13T23:45:25Z")\
**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:45pm UTC](https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/123095/1 "2007-12-13T23:45:25Z")

</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, 4:28am UTC](https://www.ruby-forum.com/t/declaration-for-module-methods-which-need-to-be-implemented/123095/2 "2007-12-14T04:28:51Z")

</div>

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

> ```
> self.children.delete(a_child)
> 
> ```
> 
> 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

You general just make a comment in the module docs. Ie.

# The including module must define #children.

# 

module Parenting  
…  
end

Under certain conditions you might provide a default, or raise an  
error, eg.

module Parenting  
def children  
raise NoMethodError  
end  
end

T.
