Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8884: doc_ar_reflection.2.diff

File doc_ar_reflection.2.diff, 2.7 kB (added by jeremymcanally, 10 months ago)
  • activerecord/lib/active_record/reflection.rb

    old new  
    7676        @macro, @name, @options, @active_record = macro, name, options, active_record 
    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      # +:balance+ or for <tt>has_many :clients</tt> it will return +:clients+
    8181      def name 
    8282        @name 
    8383      end 
    8484 
    85       # Returns the name 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 +:composed_of+ 
     86      # or for <tt>has_many :clients</tt> will return +:has_many+
    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>
    9393      def options 
    9494        @options 
    9595      end 
    9696 
    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. 
     97      # Returns the class for the macro.  For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns the +Money+ 
     98      # class and <tt>has_many :clients</tt> returns the +Client+ class. 
    9999      def klass 
    100100        @klass ||= class_name.constantize 
    101101      end 
    102102 
     103      # Returns the class name for the macro.  For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns +Money+ 
     104      # and <tt>has_many :clients</tt> returns +Client+. 
    103105      def class_name 
    104106        @class_name ||= options[:class_name] || derive_class_name 
    105107      end 
    106108 
     109      # Returns +true+ if +self+ and +other_aggregation+ have the same +name+ attribute, +active_record+ attribute, 
     110      # and +other_aggregation+ has an options hash assigned to it. 
    107111      def ==(other_aggregation) 
    108112        name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record 
    109113      end