Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source
Show
Ignore:
Timestamp:
04/05/08 03:52:58 (8 months ago)
Author:
pratik
Message:

Improve documentation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/reflection.rb

    r8571 r9226  
    7777      end 
    7878 
    79       # Returns the name of the macro, so it would return :balance for "composed_of :balance, :class_name => 'Money'" or 
    80       # :clients for "has_many :clients"
     79      # Returns the name of the macro.  For example, <tt>composed_of :balance, :class_name => 'Money'</tt> will return 
     80      # <tt>:balance</tt> or for <tt>has_many :clients</tt> it will return <tt>:clients</tt>
    8181      def name 
    8282        @name 
    8383      end 
    8484 
    85       # Returns the type of the macro, so it would return :composed_of for 
    86       # "composed_of :balance, :class_name => 'Money'" or :has_many for "has_many :clients"
     85      # Returns the macro type. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>:composed_of</tt> 
     86      # or for <tt>has_many :clients</tt> will return <tt>:has_many</tt>
    8787      def macro 
    8888        @macro 
    8989      end 
    9090 
    91       # Returns the hash of options used for the macro, so it would return { :class_name => "Money" } for 
    92       # "composed_of :balance, :class_name => 'Money'" or {} for "has_many :clients". 
     91      # Returns the hash of options used for the macro.  For example, it would return <tt>{ :class_name => "Money" }</tt> for 
     92      # <tt>composed_of :balance, :class_name => 'Money'</tt> or +{}+ for <tt>has_many :clients</tt>. 
     93 
    9394      def options 
    9495        @options 
    9596      end 
    9697 
    97       # Returns the class for the macro, so "composed_of :balance, :class_name => 'Money'" returns the Money class and 
    98       # "has_many :clients" returns the Client class. 
     98      # Returns the class for the macro.  For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns the +Money+ 
     99      # class and <tt>has_many :clients</tt> returns the +Client+ class. 
    99100      def klass 
    100101        @klass ||= class_name.constantize 
    101102      end 
    102103 
     104      # Returns the class name for the macro.  For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt> 
     105      # and <tt>has_many :clients</tt> returns <tt>'Client'</tt>. 
    103106      def class_name 
    104107        @class_name ||= options[:class_name] || derive_class_name 
    105108      end 
    106109 
     110      # Returns +true+ if +self+ and +other_aggregation+ have the same +name+ attribute, +active_record+ attribute, 
     111      # and +other_aggregation+ has an options hash assigned to it. 
    107112      def ==(other_aggregation) 
    108113        name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record