diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-12 22:29:45 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-13 00:01:58 +0100 |
commit | 6d8dbeca6b0e676145ecdbba38f2fe56b74b4f8f (patch) | |
tree | b22893ce88e318cf2f60e2326e93a1dda19ba085 | |
parent | ac687ed651773fccecbc22cd6d8b07d5439ceb76 (diff) | |
download | rails-6d8dbeca6b0e676145ecdbba38f2fe56b74b4f8f.tar.gz rails-6d8dbeca6b0e676145ecdbba38f2fe56b74b4f8f.tar.bz2 rails-6d8dbeca6b0e676145ecdbba38f2fe56b74b4f8f.zip |
Avoid double super call in some cases.
If super was false earlier, it is still going to be false, so we don't
need to call it again at the end of the method.
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index baebc91192..39ece6d3b3 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -431,15 +431,14 @@ module ActiveModel alias :respond_to_without_attributes? :respond_to? def respond_to?(method, include_private_methods = false) if super - return true + true elsif !include_private_methods && super(method, true) # If we're here then we haven't found among non-private methods # but found among all methods. Which means that the given method is private. - return false - elsif match_attribute_method?(method.to_s) - return true + false + else + !match_attribute_method?(method.to_s).nil? end - super end protected |