Permalink
Browse files

Fix performance bug in AttibuteMethods#respond_to? in handling of pri…

…vate 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 <michael@koziarski.com>
[#1173 state:committed]
  • Loading branch information...
Aliaksey Kandratsenka authored and NZKoz committed Oct 3, 2008
1 parent 6080b73 commit f550c8625739106e957e4260d3d592a9665fc943
Showing with 3 additions and 1 deletion.
  1. +3 −1 activerecord/lib/active_record/attribute_methods.rb
@@ -342,7 +342,9 @@ def respond_to?(method, include_private_methods = false)
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

0 comments on commit f550c86

Please sign in to comment.