Skip to content

Commit

Permalink
Fix performance bug in AttibuteMethods#respond_to? in handling of pri…
Browse files Browse the repository at this point in the history
…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 4, 2008
1 parent 6080b73 commit f550c86
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/attribute_methods.rb
Expand Up @@ -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
Expand Down

0 comments on commit f550c86

Please sign in to comment.