From f550c8625739106e957e4260d3d592a9665fc943 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Fri, 3 Oct 2008 13:40:51 +0300 Subject: 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. Signed-off-by: Michael Koziarski [#1173 state:committed] --- activerecord/lib/active_record/attribute_methods.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index e5486738f0..1c753524de 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 -- cgit v1.2.3