aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder/association.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-09 00:48:56 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-09 00:48:56 -0300
commit0ee7331c35994e543df396548c5b455c00c96cb7 (patch)
tree69106bb7c92fe315ee09a95cc884049c749edb57 /activerecord/lib/active_record/associations/builder/association.rb
parent941516dabcc5fd02eb736f457197bd115c85f2fb (diff)
downloadrails-0ee7331c35994e543df396548c5b455c00c96cb7.tar.gz
rails-0ee7331c35994e543df396548c5b455c00c96cb7.tar.bz2
rails-0ee7331c35994e543df396548c5b455c00c96cb7.zip
Define the association extensions without need to have a builder
instance
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/association.rb')
-rw-r--r--activerecord/lib/active_record/associations/builder/association.rb12
1 files changed, 6 insertions, 6 deletions
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)