Permalink
Browse files

defning extensions happens once, no need to cache

  • Loading branch information...
1 parent 655953c commit b5c4274a34d6815415111369d09e6249ccf588f1 @tenderlove tenderlove committed Aug 1, 2013
Showing with 3 additions and 5 deletions.
  1. +3 −5 activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -32,7 +32,9 @@ def define_callbacks(model, reflection)
def define_extensions(model)
if block_extension
- @extension_module = mod = Module.new(&block_extension)
+ mod = Module.new(&block_extension)
+ extension_module_name = "#{model.name.demodulize}#{name.to_s.camelize}AssociationExtension"
+
silence_warnings do
model.parent.const_set(extension_module_name, mod)
end
@@ -47,10 +49,6 @@ def define_extensions(model)
end
end
- def extension_module_name
- @extension_module_name ||= "#{model.name.demodulize}#{name.to_s.camelize}AssociationExtension"
- end
-
def define_callback(model, callback_name)
full_callback_name = "#{callback_name}_for_#{name}"

0 comments on commit b5c4274

Please sign in to comment.