Re: Syntax for calling the has_many class methods

dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
Wed, 11 Oct 2006 15:52:46 -0000

Hi --

On Wed, 11 Oct 2006, Jeff wrote:

>
> I get it, thanks.  I misunderstood the API documentation.  It explains
> that has_many, et al are class methods.  Then it uses a diagram syntax
> like this to describe the methods that has_many creates:
>
> Firm#clients<<
>
> Class#method is a syntax used to illustrate class methods in the
> PickAxe book.  So I assumed clients<< was a class method, when in
fact
> it is an instance method.

The #method notation is actually for an instance method, like
String#split.  Class methods are usually indicated like this:
ActiveRecord::Base.has_many.

But if the class whose instance method it is is Class, you''d get
Class#method....  So, for example, it''s correct to refer to
Class#new, since new is an instance method of class.


David

--
                   David A. Black |
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
Author of "Ruby for Rails"   [1] | Ruby/Rails training &
consultancy [3]
DABlog (DAB''s Weblog)        [2] | Co-director, Ruby Central, Inc.
[4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org