S
Surendra Singhi
Hello,
When I try the code below I get an error. Why is it so? Am I misunderstanding
how modules behave? How should the module be written so that `who_am_i' is
added as a method to the class Phonograph.
module Debug
def self.who_am_i?
"#{self.class.name} (\##{self.id}): #{self.to_s}"
end
end
class Phonograph
include Debug
end
Phonograph.who_am_i?
Thanks.
--
Surendra Singhi
http://ssinghi.kreeti.com, http://www.kreeti.com
Read the latest news at: http://news.kreeti.com
,----
| "O thou my friend! The prosperity of Crime is like unto the lightning,
| whose traitorous brilliancies embellish the atmosphere but for an
| instant, in order to hurl into death's very depths the luckless one
| they have dazzled." -- Marquis de Sade
`----
When I try the code below I get an error. Why is it so? Am I misunderstanding
how modules behave? How should the module be written so that `who_am_i' is
added as a method to the class Phonograph.
module Debug
def self.who_am_i?
"#{self.class.name} (\##{self.id}): #{self.to_s}"
end
end
class Phonograph
include Debug
end
Phonograph.who_am_i?
Thanks.
--
Surendra Singhi
http://ssinghi.kreeti.com, http://www.kreeti.com
Read the latest news at: http://news.kreeti.com
,----
| "O thou my friend! The prosperity of Crime is like unto the lightning,
| whose traitorous brilliancies embellish the atmosphere but for an
| instant, in order to hurl into death's very depths the luckless one
| they have dazzled." -- Marquis de Sade
`----