diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-01 09:37:24 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-01 11:02:15 -0700 |
commit | 35f94acf55f0d4dbcba747601434736685e9924f (patch) | |
tree | 71ff4e348b435c9e44a0197fbc37d72081bf65bb /activerecord/lib | |
parent | 69339e54d3464c6e4193ce744f975fd52b348449 (diff) | |
download | rails-35f94acf55f0d4dbcba747601434736685e9924f.tar.gz rails-35f94acf55f0d4dbcba747601434736685e9924f.tar.bz2 rails-35f94acf55f0d4dbcba747601434736685e9924f.zip |
separate some mutations from reflection construction
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/builder/belongs_to.rb | 6 |
2 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 a8559d9d2d..9800013ee5 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -26,6 +26,7 @@ module ActiveRecord::Associations::Builder raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol) builder = new(model, name, scope, options, &block) + builder.define_accessors model.generated_feature_methods builder.build end @@ -49,12 +50,7 @@ module ActiveRecord::Associations::Builder end end - def mixin - @model.generated_feature_methods - end - def build - define_accessors(mixin) configure_dependency if options[:dependent] reflection = ActiveRecord::Reflection.create(macro, name, scope, options, model) Association.extensions.each do |extension| diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 81293e464d..0c3b3847cc 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -23,6 +23,11 @@ module ActiveRecord::Associations::Builder [:destroy, :delete] end + def define_accessors(mixin) + super + add_counter_cache_methods mixin + end + private def add_counter_cache_methods(mixin) @@ -72,7 +77,6 @@ module ActiveRecord::Associations::Builder def add_counter_cache_callbacks(reflection) cache_column = reflection.counter_cache_column - add_counter_cache_methods mixin association = self model.after_create lambda { |record| |