Equivalent of Java static code block in Ruby?

If you're using fastcgi/webrick/mongrel (not plain cgi) and your
RAILS_ENV is set to "production" (which, by default will set the class
loading mechanism to 'require' rather than 'load'), you should get the
code only executed once (at least that's my understanding).

In general, if you're asking questions about how to do something in a
rails environment, mention that, as much of the behaviour seen in rails
is quite different from that in a standard ruby application (which is
what you'll find most of the answers in relation to).

ยทยทยท

-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Wes Gamble
Sent: Wednesday, 12 April 2006 7:18 AM
To: ruby-talk ML
Subject: Re: Equivalent of Java static code block in Ruby?

That's fine but I only want it executed ONCE the first time
the class is
loaded.

I have a Rails application that creates a new INSTANCE of a
controller
class every time a certain URL is requested.

All of the code that isn't in methods is being executed every
time the
instance is created.

So do I have to guard my code to ensure that it's only executed once?

Thanks,
Wes