Tim Perrett
2007-Dec-22  00:50 UTC
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
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Bala Paranj
2007-Dec-22  03:32 UTC
Re: How do the AR singleton methods actually do there magic?
Watch the MetaProgramming - Extending Ruby for Fun and Profit screencast by Dave Thomas. 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 Perrett <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > -- > Posted via http://www.ruby-forum.com/. > > > >-- http://www.rubyplus.org/ Free Ruby Screencasts --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tim Perrett
2007-Dec-22  12:17 UTC
Re: How do the AR singleton methods actually do there magic?
Excellent resources - thanks Bala Tim -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---