Changeset 4206
- Timestamp:
- 04/11/06 01:10:42 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/associations.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/associations/association_proxy.rb (modified) (1 diff)
- trunk/activerecord/test/associations_extensions_test.rb (modified) (1 diff)
- trunk/activerecord/test/fixtures/developer.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r4203 r4206 1 *SVN* 2 3 * Allow multiple association extensions with :extend option (closes #4666) [Josh Susser] 4 5 class Account < ActiveRecord::Base 6 has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] 7 end 8 9 1 10 *1.14.2* (April 9th, 2005) 2 11 trunk/activerecord/lib/active_record/associations.rb
r4179 r4206 214 214 # class Company < ActiveRecord::Base 215 215 # has_many :people, :extend => FindOrCreateByNameExtension 216 # end 217 # 218 # If you need to use multiple named extension modules, you can specify an array of modules with the :extend option. 219 # In the case of name conflicts between methods in the modules, methods in modules later in the array supercede 220 # those earlier in the array. Example: 221 # 222 # class Account < ActiveRecord::Base 223 # has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] 216 224 # end 217 225 # trunk/activerecord/lib/active_record/associations/association_proxy.rb
r3961 r4206 9 9 def initialize(owner, reflection) 10 10 @owner, @reflection = owner, reflection 11 proxy_extend(reflection.options[:extend]) if reflection.options[:extend]11 Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) } 12 12 reset 13 13 end trunk/activerecord/test/associations_extensions_test.rb
r2897 r4206 19 19 assert_equal projects(:action_controller), developers(:david).projects_extended_by_name.find_most_recent 20 20 end 21 22 def test_named_two_extensions_on_habtm 23 assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_twice.find_most_recent 24 assert_equal projects(:active_record), developers(:david).projects_extended_by_name_twice.find_least_recent 25 end 21 26 22 27 def test_marshalling_extensions trunk/activerecord/test/fixtures/developer.rb
r2940 r4206 2 2 def find_most_recent 3 3 find(:first, :order => "id DESC") 4 end 5 end 6 7 module DeveloperProjectsAssociationExtension2 8 def find_least_recent 9 find(:first, :order => "id ASC") 4 10 end 5 11 end … … 17 23 :association_foreign_key => "project_id", 18 24 :extend => DeveloperProjectsAssociationExtension 25 26 has_and_belongs_to_many :projects_extended_by_name_twice, 27 :class_name => "Project", 28 :join_table => "developers_projects", 29 :association_foreign_key => "project_id", 30 :extend => [DeveloperProjectsAssociationExtension, DeveloperProjectsAssociationExtension2] 19 31 20 32 has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'