Here''s my first little attempt at Ruby metaprogramming. It''s
an
extension of ActiveRecord::Base to allow for preloading reference data
that is not changed (at least not while the app is running)
module ActiveRecord
class Base
def self.preload
cattr_reader :all
class_eval("@@all = self.find(:all)")
end
end
end
class Something < ActiveRecord::Base
preload
end
Then, in a controller, say, you can access the preloaded instances as
Something.all().
As always, I appreciate your comments.
Michael
--
Michael Schuerig I am the sum total of the parts
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org I control
directly.
http://www.schuerig.de/michael/ --Daniel C. Dennett, Elbow Room