# Module and protected/private functions

**URL:** <https://www.ruby-forum.com/t/module-and-protected-private-functions/193690>\
**Category:** Ruby\
**Created:** [August 22, 2010, 2:33pm UTC](https://www.ruby-forum.com/t/module-and-protected-private-functions/193690 "2010-08-22T14:33:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 22, 2010, 2:33pm UTC](https://www.ruby-forum.com/t/module-and-protected-private-functions/193690/1 "2010-08-22T14:33:48Z")

</div>

Is it possible to declare parts of a module as private or protected to  
import these properties via mixin into classes?

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 23, 2010, 12:03am UTC](https://www.ruby-forum.com/t/module-and-protected-private-functions/193690/2 "2010-08-23T00:03:46Z")

</div>

On Sun, Aug 22, 2010 at 2:35 PM, Fritz T. wrote:

> ## Is it possible to declare parts of a module as private or protected to import these properties via mixin into classes?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

as a matter of fact it is,

> > module M  
> > def a; end  
> > protected  
> > def aa; end  
> > private  
> > def aaa; end  
> > end  
> > =\> nil  
> > include M  
> > =\> Object  
> > private\_methods.grep /\Aa/  
> > =\> [:aaa, :at\_exit, :abort, :autoload, :autoload?]  
> > protected\_methods.grep /\Aa/  
> > =\> [:aa]  
> > methods.grep /\Aa/  
> > =\> [:a, :aa]

HTH  
Robert
