From 23517aa9a4125c9060562b87281515826e2d66cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 8 Oct 2013 23:59:44 -0300 Subject: Push define_accessors to class level since we don't need anythig from the instance --- .../lib/active_record/associations/builder/association.rb | 8 ++++---- activerecord/lib/active_record/associations/builder/belongs_to.rb | 4 ++-- .../active_record/associations/builder/singular_association.rb | 4 ++-- 3 files changed, 8 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 fa46ea060e..fe8274e1d8 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -23,7 +23,7 @@ module ActiveRecord::Associations::Builder def self.build(model, name, scope, options, &block) builder = create_builder model, name, scope, options, &block reflection = builder.build(model) - builder.define_accessors model, reflection + define_accessors model, reflection define_callbacks model, reflection builder.define_extensions model reflection @@ -84,11 +84,11 @@ module ActiveRecord::Associations::Builder # end # # Post.first.comments and Post.first.comments= methods are defined by this method... - def define_accessors(model, reflection) + def self.define_accessors(model, reflection) mixin = model.generated_feature_methods name = reflection.name - self.class.define_readers(mixin, name) - self.class.define_writers(mixin, name) + define_readers(mixin, name) + define_writers(mixin, name) end def self.define_readers(mixin, name) diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 8279fcdaa6..c0b1847f33 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -18,9 +18,9 @@ module ActiveRecord::Associations::Builder add_touch_callbacks(model, reflection) if reflection.options[:touch] end - def define_accessors(mixin, reflection) + def self.define_accessors(mixin, reflection) super - self.class.add_counter_cache_methods mixin + add_counter_cache_methods mixin end private diff --git a/activerecord/lib/active_record/associations/builder/singular_association.rb b/activerecord/lib/active_record/associations/builder/singular_association.rb index 4dc45d4d25..8e6bd7fcc6 100644 --- a/activerecord/lib/active_record/associations/builder/singular_association.rb +++ b/activerecord/lib/active_record/associations/builder/singular_association.rb @@ -6,9 +6,9 @@ module ActiveRecord::Associations::Builder super + [:remote, :dependent, :counter_cache, :primary_key, :inverse_of] end - def define_accessors(model, reflection) + def self.define_accessors(model, reflection) super - self.class.define_constructors(model.generated_feature_methods, reflection.name) if reflection.constructable? + define_constructors(model.generated_feature_methods, reflection.name) if reflection.constructable? end # Defines the (build|create)_association methods for belongs_to or has_one association -- cgit v1.2.3