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 methods on claims mentor training form #1086

Merged
merged 3 commits into from
Oct 7, 2024

Commits on Oct 7, 2024

  1. Move logic closer to the code that needs it

    I've relocated the logic that was originally defined as
    `Claims::Claim::MentorTrainingForm#max_hours_equals_maximum_claimable_hours?`
    because it was only needed and used in the component
    `Claims::Claim::MentorTrainingForm::DisclaimerComponent`.
    
    The component spec already covered the required behaviour, so I was able
    to simply move the code and cut out an unnecessary layer of abstraction.
    ollietreend committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    edd127a View commit details
    Browse the repository at this point in the history
  2. Make custom_hours_selected? method private

    This method doesn't need to be part of the form object's public
    interface, so I've made it private. It's only used by the validation
    rules inside this class.
    
    I've also dropped the memoization of this method. It's a simple and
    cheap enough method to run that I don't think it's harmful to run it
    twice. It simplifies the code and doesn't add any significant overhead.
    ollietreend committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    d1e6928 View commit details
    Browse the repository at this point in the history
  3. Stop memoizing max_hours

    This value is already memoized in the training allowance object. There's
    no need to double memoize it.
    ollietreend committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    0f9fe17 View commit details
    Browse the repository at this point in the history