From: Maciej Tomaka Date: 2008-09-02T02:41:37+09:00 Subject: Re: included() vs extended() > So my question is: given that extend() is implemented (I think) using > metclass.include(), and that the end result of both is identical, how > come > Hooks.included is not called when using extend()? It seems reasonable > that > both the included() and extended() hooks should be called in this > situation, > though I can just as well see the argument against doing this. Anyone > care > to enlighten/persuade me as to why this behaviour exists? In ruby everything is an object. So even class is an object. Still we have extend and include which are not the same methods: include => includes code into class. extend => extends using module, appends class methods. bar = Bar.new bar - object of class Bar bar.class - class of object bar Bar - class Bar, object of class Class Bar.metaclass - class of class Bar :) Bar.metaclass.send(:include, Hooks) is called on class of class Bar. So you got the methods as instance methods of class Bar. My explaination may not have sense for you. Better read Why’s Poignant Guide to Ruby - chapter 6 and/or Dr. Nic Williams PDF from euruko conference http://www.euruko2008.org/pages/show/2-program. Best Regards Maciej -- Posted via http://www.ruby-forum.com/.