# Did this stop working? Or did it ever work? (metamagic)

**URL:** <https://www.ruby-forum.com/t/did-this-stop-working-or-did-it-ever-work-metamagic/136431>\
**Category:** Ruby\
**Created:** [May 2, 2008, 12:43am UTC](https://www.ruby-forum.com/t/did-this-stop-working-or-did-it-ever-work-metamagic/136431 "2008-05-02T00:43:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [May 2, 2008, 12:43am UTC](https://www.ruby-forum.com/t/did-this-stop-working-or-did-it-ever-work-metamagic/136431/1 "2008-05-02T00:43:06Z")

</div>

I wrote a tutorial a few months ago that describes how/why the following  
worked:

module Translator

module ClassMethods

```
def translate
end

```

end

def included(receiver)  
receiver.extend(ClassMethods)  
end

end

class C

include Translator

end

But, now it doesn’t work.

Effectively I expect the translate method to become a class-level method  
of C. Instead I’m told C doesn’t know about that method.

If I call C.extend(Translator::ClassMethods) I get what I’d expect.

Have I been wrong this entire time or did something change?

ruby -v  
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-darwin9.2.2]

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [May 2, 2008, 12:57am UTC](https://www.ruby-forum.com/t/did-this-stop-working-or-did-it-ever-work-metamagic/136431/2 "2008-05-02T00:57:29Z")

</div>

On May 2, 2008, at 0:43, Daniel W. wrote:

> module Translator
> 
> module ClassMethods
> 
> def translate  
> end
> 
> end
> 
> def included(receiver)

You forgot the self. here. ``included’’ is a module method.  
def self.included(receiver)  
Then it works.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [May 2, 2008, 1:08am UTC](https://www.ruby-forum.com/t/did-this-stop-working-or-did-it-ever-work-metamagic/136431/3 "2008-05-02T01:08:17Z")

</div>

Mikael HÃ¸ilund wrote:

> On May 2, 2008, at 0:43, Daniel W. wrote:
> 
> > module Translator
> > 
> > module ClassMethods
> > 
> > def translate  
> > end
> > 
> > end
> > 
> > def included(receiver)
> 
> You forgot the self. here. ``included’’ is a module method.  
> def self.included(receiver)  
> Then it works.

_face palm_

Thanks, Mikael. Glad I wasn’t _too_ far off. 🙂
