From: Kenny Meyer Date: 2013-08-01T06:34:10+09:00 Subject: Re: Method tracker - Need assistance --047d7b10cb375de91804e2d57cb6 Content-Type: text/plain; charset=UTF-8 Duh... thanks, for pointing out this small detail. Kenny Meyer I make Software. www.kennymeyer.net | +(595) 982 52 74 11 On Wed, Jul 31, 2013 at 5:25 PM, Ryan Davis wrote: > > On Jul 31, 2013, at 13:44 , Kenny Meyer wrote: > > > I would like to write an includable method tracker, which logs about > added methods to a class. > > > > module MethodTracker > > def self.method_added(method_name) > > puts "Tracking #{method_name}" > > end > > end > > > > class Factory > > include MethodTracker > > > > def build > > end > > end > > > > This is my code, however when the `Factory` class is defined there is no > message shown. Can you give me a hint? > > method_added is a class method, so you need to extend Factory, not include. > > module MethodTracker > def method_added(method_name) > puts "Tracking #{method_name}" > end > end > > class Factory > extend MethodTracker > > def build > end > end > > > --047d7b10cb375de91804e2d57cb6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Duh... thanks, for pointing out this small detail.

Kenny Meyer

I make S= oftware.
www.ken= nymeyer.net =C2=A0| =C2=A0+(595) 982 52 74 11


On Wed, Jul 31, 2013 at 5:25 PM, Ryan Da= vis <ryand-ruby@zenspider.com> wrote:

On Jul 31, 2013, at 13:44 , Kenny Meyer <kenny@kennymeyer.net> wrote:

> I would like to write an includable method tracker, which logs about a= dded methods to a class.
>
> module MethodTracker
> =C2=A0 def self.method_added(method_name)
> =C2=A0 =C2=A0 puts "Tracking #{method_name}"
> =C2=A0 end
> end
>
> class Factory
> =C2=A0 include MethodTracker
>
> =C2=A0 def build
> =C2=A0 end
> end
>
> This is my code, however when the `Factory` class is defined there is = no message shown. Can you give me a hint?

method_added is a class method, so you need to extend Factory, not in= clude.

module MethodTracker
=C2=A0 def method_added(method_name)
=C2=A0 =C2=A0 puts "Tracking #{method_name}" =C2=A0 end
end

class Factory
=C2=A0 extend MethodTracker

=C2=A0 def build
=C2=A0 end
end



--047d7b10cb375de91804e2d57cb6--