On 4/11/06, Wes G. [email protected] wrote:
Or do I have to put the code into an initialize method in my class and
then guard it so that it’s only executed once?
Posted via http://www.ruby-forum.com/.
Well unless I missunderstood this is an easy one
In order to execute something when the class is loaded you just put it
The attr_* methods are a good example, they are executed when the class
statement is executed and their receiver is
of course the class itself.
So that would be like
@bar = “foo”
def statements are of course defining instance methods so what if we
static methods (well there is no such thing), class methods
there are at least 3 options
class << self
def Foo.static # not sure if it works is a maintainence nightmare
Hope that helps
Deux choses sont infinies : l’univers et la bÃªtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.