aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-12 22:29:45 +0100
committerJon Leighton <j@jonathanleighton.com>2011-09-13 00:01:58 +0100
commit6d8dbeca6b0e676145ecdbba38f2fe56b74b4f8f (patch)
treeb22893ce88e318cf2f60e2326e93a1dda19ba085 /activemodel/lib/active_model
parentac687ed651773fccecbc22cd6d8b07d5439ceb76 (diff)
downloadrails-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.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb9
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