How do the AR singleton methods actually do there magic?

Hey all,

Ive been looking at the AR source code and wondering something. There is
heavy use of (for example)

class Base
class << self
#Â definitions
end
end

Now, I can see that this is how we get our nice syntax for model
validations and so forth - but what I dont get is how that actually
works behind the scences.

I found this post
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/57252
detailing what that syntax means in detail, and I get that. But what
confuses me, is how if the validations are class methods, are they
validating instances of that class? What is actually going on behind the
scenes?

If anyone can shed any light on this I would be very grateful

Cheers

Tim

Watch the MetaProgramming - Extending Ruby for Fun and Profit screencast
by
Dave T… http://www.infoq.com/presentations/metaprogramming-ruby

Check out my site www.rubyplus.org, there is a screencast on Include Vs
Extend that is also related.

On Dec 21, 2007 4:50 PM, Tim P. [email protected]
wrote:

end
scenes?


http://www.rubyplus.org/
Free Ruby Screencasts

Excellent resources - thanks Bala

Tim

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs