aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-17 21:19:44 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-17 21:19:44 +0000
commit81d619ea0d7e936bdf5a643c8731e4b3f3746b8e (patch)
tree34aef34ef446db68d9122cde405c7e75bf771101 /activerecord/lib/active_record
parent6b1901da8f2db638884d3e51f84d4392775e7667 (diff)
downloadrails-81d619ea0d7e936bdf5a643c8731e4b3f3746b8e.tar.gz
rails-81d619ea0d7e936bdf5a643c8731e4b3f3746b8e.tar.bz2
rails-81d619ea0d7e936bdf5a643c8731e4b3f3746b8e.zip
Associations macros accept extension blocks alongside modules. Closes #9346.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7504 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 8cb6bd02ac..a508a9c94d 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1165,7 +1165,7 @@ module ActiveRecord
:extend
)
- options[:extend] = create_extension_module(association_id, extension) if block_given?
+ options[:extend] = create_extension_modules(association_id, extension, options[:extend]) if block_given?
create_reflection(:has_many, association_id, options, self)
end
@@ -1203,7 +1203,7 @@ module ActiveRecord
:extend
)
- options[:extend] = create_extension_module(association_id, extension) if block_given?
+ options[:extend] = create_extension_modules(association_id, extension, options[:extend]) if block_given?
reflection = create_reflection(:has_and_belongs_to_many, association_id, options, self)
@@ -1346,14 +1346,14 @@ module ActiveRecord
sql =~ /where/i ? " AND " : "WHERE "
end
- def create_extension_module(association_id, extension)
+ def create_extension_modules(association_id, block_extension, extensions)
extension_module_name = "#{self.to_s}#{association_id.to_s.camelize}AssociationExtension"
silence_warnings do
- Object.const_set(extension_module_name, Module.new(&extension))
+ Object.const_set(extension_module_name, Module.new(&block_extension))
end
-
- extension_module_name.constantize
+
+ Array(extensions).push(extension_module_name.constantize)
end
class JoinDependency # :nodoc: