Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and clean up number helpers #10996

Merged
merged 1 commit into from Dec 3, 2013
Merged

Refactor and clean up number helpers #10996

merged 1 commit into from Dec 3, 2013

Commits on Jul 1, 2013

  1. 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`
    Matt Bridges committed Jul 1, 2013
    1 Configuration menu
    Copy the full SHA
    2da9d67 View commit details
    Browse the repository at this point in the history