1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

16 commits

Author SHA1 Message Date
Carlos Antonio da Silva
443c31f8fc Nodoc missing number helper classes in AS [ci skip]
These classes are not meant to be public.
2013-12-11 20:01:54 -02:00
Carlos Antonio da Silva
d5332de379 Remove earlier return in favor of conditional 2013-12-03 20:26:57 -02:00
Carlos Antonio da Silva
59ba94e8a2 Change delimiter check order: first check if it is present
This reads a lot better, and we won't need to try start_with? for blank
delimiters.

Also rename method name to read better.
2013-12-03 20:26:57 -02:00
Carlos Antonio da Silva
a63d8cd9e1 Make both conversion methods work similarly
The conversion without area code already changed the passed number in
place, so change the other method to do the same.
2013-12-03 20:26:56 -02:00
Carlos Antonio da Silva
308ed01f14 Remove useless empty string 2013-12-03 20:26:56 -02:00
Carlos Antonio da Silva
da507b71f6 No need for #tap 2013-12-03 20:26:56 -02:00
Carlos Antonio da Silva
55afd62f23 Avoid a hash creation since defaults is a new hash already 2013-12-03 20:26:56 -02:00
Carlos Antonio da Silva
e56a553c95 Stop using local variables everywhere, make use of the reader 2013-12-03 20:26:56 -02:00
Carlos Antonio da Silva
4e19ef9b25 Refactor to avoid earlier returns 2013-12-03 20:26:56 -02:00
Carlos Antonio da Silva
72db343334 Rename variable that holds whether or not the class should validate a float number 2013-12-03 20:26:56 -02:00
Rafael Mendonça França
d7d11f0dab :sicssors: 2013-12-02 22:32:22 -02:00
Rafael Mendonça França
d752ae16ab Options are not optional 2013-12-02 22:32:21 -02:00
Rafael Mendonça França
5c04ca87d8 Make execute priave API 2013-12-02 22:32:21 -02:00
Rafael Mendonça França
d3b93e403b Make load of NumberHelper thread safe 2013-12-02 22:12:36 -02:00
Rafael Mendonça França
fc73ebf332 Merge pull request #10996 from mattdbridges/number-helper-refactor
Refactor and clean up number helpers

Conflicts:
	activesupport/lib/active_support/number_helper.rb
2013-12-02 20:50:03 -02:00
Matt Bridges
2da9d67c27 Extract ActiveSupport::NumberHelper methods to classes
Due to the overall complexity of each method individually as well as the
global shared private module methods, this pulls each helper into it's
own converter class inheriting from a generic `NumberBuilder` class.

* The `NumberBuilder` class contains the private methods needed for each helper
method an eliminates the need for special definition of specialized private
module methods.
* The `ActiveSupport::NumberHelper::DEFAULTS` constant has been moved
into the `NumberBuilder` class because the `NumberBuilder` is the only
class which needs access to it.
* For each of the builders, the `#convert` method is broken down to
smaller parts and extracted into private methods for clarity of purpose.
* Most of the mutation that once was necessary has now been eliminated.
* Several of the mathematical operations for percentage, delimited, and
rounded have been moved into private methods to ease readability and
clarity.
* Internationalization is still a bit crufty, and definitely could be
improved, but it is functional and a bit easier to follow.

The following helpers were extracted into their respective classes.

* `#number_to_percentage` -> `NumberToPercentageConverter`
* `#number_to_delimited` -> `NumberToDelimitedConverter`
* `#number_to_phone` -> `NumberToPhoneConverter`
* `#number_to_currency` -> `NumberToCurrencyConverter`
* `#number_to_rounded` -> `NumberToRoundedConverter`
* `#number_to_human_size` -> `NumberToHumanSizeConverter`
* `#number_to_human` -> `NumberToHumanConverter`
2013-07-01 12:31:36 -05:00