From 86588f9bc4d6214a8e625f97fcadb246592c41c0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 1 Aug 2013 11:28:12 -0700 Subject: push more mutations outside the factory method --- .../lib/active_record/associations/builder/association.rb | 4 ++++ .../associations/builder/collection_association.rb | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index ef397fdb52..76c91ecb72 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -29,6 +29,7 @@ module ActiveRecord::Associations::Builder reflection = builder.build builder.define_accessors model.generated_feature_methods builder.define_callbacks model, reflection + builder.define_extensions model reflection end @@ -68,6 +69,9 @@ module ActiveRecord::Associations::Builder options.assert_valid_keys(valid_options) end + def define_extensions(model) + end + def define_callbacks(model, reflection) add_before_destroy_callbacks(model, name) if options[:dependent] Association.extensions.each do |extension| diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb index 04e017a92a..fd40b320e3 100644 --- a/activerecord/lib/active_record/associations/builder/collection_association.rb +++ b/activerecord/lib/active_record/associations/builder/collection_association.rb @@ -14,8 +14,8 @@ module ActiveRecord::Associations::Builder attr_reader :block_extension - def initialize(*args) - super(*args) + def initialize(model, name, scope, options) + super @mod = nil if block_given? @mod = Module.new(&Proc.new) @@ -23,12 +23,6 @@ module ActiveRecord::Associations::Builder end end - def build - define_extensions(model) - reflection = super - reflection - end - def define_callbacks(model, reflection) super CALLBACKS.each { |callback_name| define_callback(model, callback_name) } -- cgit v1.2.3