From 40b065bf2301e2e05a5866770da192d0f8b13025 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Fri, 3 Oct 2008 13:40:51 +0300 Subject: [PATCH] Fix performance bug in AttibuteMethods#respond_to? in handling of private methods We have hit dramatic increase in tests time after upgrading rails. Profiling revealed this particular place. After this fix our test times returned back to norm. --- .../lib/active_record/attribute_methods.rb | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index e548673..1c75352 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -342,7 +342,9 @@ module ActiveRecord method_name = method.to_s if super return true - elsif self.private_methods.include?(method_name) && !include_private_methods + elsif !include_private_methods && super(method, true) + # If we're here than we haven't found among non-private methods + # but found among all methods. Which means that given method is private. return false elsif !self.class.generated_methods? self.class.define_attribute_methods -- 1.5.6.5