diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-05 23:55:17 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-05 23:55:17 -0200 |
commit | ab51b285e2cccdc0cbdcd2daa04a7fd2fbb661ea (patch) | |
tree | 72e7e0a7dd85eb874cafb732b8217ef9ed36b51f /activesupport/lib/active_support | |
parent | d6e3fd775b8a0277b07b06c22c29f66dbafe6559 (diff) | |
download | rails-ab51b285e2cccdc0cbdcd2daa04a7fd2fbb661ea.tar.gz rails-ab51b285e2cccdc0cbdcd2daa04a7fd2fbb661ea.tar.bz2 rails-ab51b285e2cccdc0cbdcd2daa04a7fd2fbb661ea.zip |
Refatoring the method to avoid shot-circuit return
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/to_param.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/to_param.rb b/activesupport/lib/active_support/core_ext/object/to_param.rb index e40846e7d6..13be0038c2 100644 --- a/activesupport/lib/active_support/core_ext/object/to_param.rb +++ b/activesupport/lib/active_support/core_ext/object/to_param.rb @@ -51,9 +51,12 @@ class Hash # # This method is also aliased as +to_query+. def to_param(namespace = nil) - return (namespace ? nil.to_query(namespace) : '') if empty? - collect do |key, value| - value.to_query(namespace ? "#{namespace}[#{key}]" : key) - end.sort! * '&' + if empty? + namespace ? nil.to_query(namespace) : '' + else + collect do |key, value| + value.to_query(namespace ? "#{namespace}[#{key}]" : key) + end.sort! * '&' + end end end |