From 24faddd60c5fd148c8264898aeca2d5f36b25a4b Mon Sep 17 00:00:00 2001 From: Alexander Uvarov Date: Sun, 13 Feb 2011 22:27:33 +0500 Subject: Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord, so it's flexible now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#6428 state:resolved] Signed-off-by: José Valim --- activerecord/lib/active_record/attribute_methods.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/lib/active_record/attribute_methods.rb') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 284ae2bebc..5833c65893 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -10,7 +10,18 @@ module ActiveRecord # Generates all the attribute related methods for columns in the database # accessors, mutators and query methods. def define_attribute_methods + return if attribute_methods_generated? super(column_names) + @attribute_methods_generated = true + end + + def attribute_methods_generated? + @attribute_methods_generated ||= false + end + + def undefine_attribute_methods(*args) + super + @attribute_methods_generated = false end # Checks whether the method is defined in the model or any of its subclasses -- cgit v1.2.3