Changeset 9226 for trunk/activerecord/lib/active_record/reflection.rb
- Timestamp:
- 04/05/08 03:52:58 (8 months ago)
- Files:
-
- trunk/activerecord/lib/active_record/reflection.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/reflection.rb
r8571 r9226 77 77 end 78 78 79 # Returns the name of the macro , so it would return :balance for "composed_of :balance, :class_name => 'Money'" or80 # :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>. 81 81 def name 82 82 @name 83 83 end 84 84 85 # Returns the type of the macro, so it would return :composed_of for86 # "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>. 87 87 def macro 88 88 @macro 89 89 end 90 90 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 93 94 def options 94 95 @options 95 96 end 96 97 97 # Returns the class for the macro , so "composed_of :balance, :class_name => 'Money'" returns the Money class and98 # "has_many :clients" returns the Clientclass.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. 99 100 def klass 100 101 @klass ||= class_name.constantize 101 102 end 102 103 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>. 103 106 def class_name 104 107 @class_name ||= options[:class_name] || derive_class_name 105 108 end 106 109 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. 107 112 def ==(other_aggregation) 108 113 name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record