From 0ee7331c35994e543df396548c5b455c00c96cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 9 Oct 2013 00:48:56 -0300 Subject: Define the association extensions without need to have a builder instance --- .../lib/active_record/associations/builder/association.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record/associations/builder/association.rb') diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index fe8274e1d8..3f63326b16 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -21,15 +21,15 @@ module ActiveRecord::Associations::Builder attr_reader :name, :scope, :options def self.build(model, name, scope, options, &block) - builder = create_builder model, name, scope, options, &block + extension = define_extensions model, name, &block + builder = create_builder model, name, scope, options, extension reflection = builder.build(model) define_accessors model, reflection define_callbacks model, reflection - builder.define_extensions model reflection end - def self.create_builder(model, name, scope, options, &block) + def self.create_builder(model, name, scope, options, extension = nil) raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol) if scope.is_a?(Hash) @@ -37,10 +37,10 @@ module ActiveRecord::Associations::Builder scope = nil end - new(name, scope, options, &block) + new(name, scope, options, extension) end - def initialize(name, scope, options) + def initialize(name, scope, options, extension) @name = name @scope = scope @options = options @@ -68,7 +68,7 @@ module ActiveRecord::Associations::Builder options.assert_valid_keys(valid_options) end - def define_extensions(model) + def self.define_extensions(model, name) end def self.define_callbacks(model, reflection) -- cgit v1.2.3