# Pluginfactory.rb - my door to insanity

**URL:** <https://www.ruby-forum.com/t/pluginfactory-rb-my-door-to-insanity/71807>\
**Category:** Ruby\
**Created:** [February 22, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/pluginfactory-rb-my-door-to-insanity/71807 "2006-02-22T14:23:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![merc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f07891/32.png) [@merc](https://www.ruby-forum.com/u/merc)\
**Post date:** [February 22, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/pluginfactory-rb-my-door-to-insanity/71807/1 "2006-02-22T14:23:06Z")

</div>

Hello,

As a matter of principle, I am studying the pluginfactory plugin  
([http://raa.ruby-lang.org/project/pluginfactory/](http://raa.ruby-lang.org/project/pluginfactory/)).

At first, I thought the author was insane (in a good way!).

I am going bananas, trying to understand the pluginfactory.rb module.

At one point, he defines:

```
### Inheritance callback -- Register subclasses in the

```

derivatives hash  
### so that ::create knows about them.  
def inherited( subclass )

NOW! You night say "No wait, inherited needs to be a class method,  
not a n instance method.

Well, the module does this when it’s included:

```
     ### Inclusion callback -- extends the including class.
     def self::included( klass )
             klass.extend( self )
     end

```

This means that all of the instance methods defined in the plugin  
become… part of the class!  
This opened in my brain the door to insanity.

Is this technique used a lot? What I don’t like about it, is that the  
instance methods in the module become both instance methods and class  
methods in the includer.  
This could possibly create clutter in the class’ methods.

For what I understand, with include/extend is never, ever possible to  
add class methods to a class using include or extend (of course, you  
can use inheritance, but that would be too “normal”).

Guys, I am in awe.

Merc.

---

<div class="post-metadata">

**Author:** ![merc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f07891/32.png) [@merc](https://www.ruby-forum.com/u/merc)\
**Post date:** [February 22, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/pluginfactory-rb-my-door-to-insanity/71807/2 "2006-02-22T15:04:55Z")

</div>

Tony M. wrote:

> Hello,
> 
> For what I understand, with include/extend is never, ever possible to  
> add class methods to a class using include or extend (of course, you  
> can use inheritance, but that would be too “normal”).

why wrote about mixing in class meths as class meths:

[http://redhanded.hobix.com/bits/hyperextended.html](http://redhanded.hobix.com/bits/hyperextended.html)

---

<div class="post-metadata">

**Author:** ![merc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f07891/32.png) [@merc](https://www.ruby-forum.com/u/merc)\
**Post date:** [February 23, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/pluginfactory-rb-my-door-to-insanity/71807/3 "2006-02-23T13:03:17Z")

</div>

Hi,

OK. While this is indeed a nice “trick” (in fact, it’s really  
smart!), it still looks like a bit of a hack to me.

Does anybody know if Matz is planning on ad a method to include class  
instance methods into another class without using inheritance?

In fact… do you think that doing so is actually useful?

Bye,

Merc.
