aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/number_helper
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-12-03 19:42:49 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-12-03 20:26:56 -0200
commit4e19ef9b25e7461be654c6e5bc085addbefc459e (patch)
tree787a0d841c1517492d4f25f9e713af07d60a3452 /activesupport/lib/active_support/number_helper
parent72db343334d4188a27e9c6542d6527e091f46431 (diff)
downloadrails-4e19ef9b25e7461be654c6e5bc085addbefc459e.tar.gz
rails-4e19ef9b25e7461be654c6e5bc085addbefc459e.tar.bz2
rails-4e19ef9b25e7461be654c6e5bc085addbefc459e.zip
Refactor to avoid earlier returns
Diffstat (limited to 'activesupport/lib/active_support/number_helper')
-rw-r--r--activesupport/lib/active_support/number_helper/number_converter.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_converter.rb b/activesupport/lib/active_support/number_helper/number_converter.rb
index 537bf1e5b6..471c686997 100644
--- a/activesupport/lib/active_support/number_helper/number_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_converter.rb
@@ -119,14 +119,18 @@ module ActiveSupport
end
def initialize(number, options)
- @number = number
- @opts = options.symbolize_keys
+ @number = number
+ @opts = options.symbolize_keys
end
def execute
- return unless @number
- return @number if validate_float? && !valid_float?
- convert
+ if !@number
+ nil
+ elsif validate_float? && !valid_float?
+ @number
+ else
+ convert
+ end
end
private