Skip to content

Commit

Permalink
Fix memoization logic in Localized mixin (#465)
Browse files Browse the repository at this point in the history
Right now, the memoization logic will return `nil` if `@localizations` was set to `nil`. This means we don't have a straightforward way to reset this class-level variable. It will be important in subsequent PRs to be able to do so when running tests.

If the localizations are empty, `@localizations` will anyway be set to `{}`, not `nil`. This PR ensures that the localizations are loaded instead of early returning when `@localizations == nil`.
  • Loading branch information
danielpgross authored Nov 27, 2024
2 parents 1387547 + 1a2ef2b commit c8af9f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dev/lib/product_taxonomy/models/mixins/localized.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module ProductTaxonomy
module Localized
def localizations
return @localizations if defined?(@localizations)
return @localizations if @localizations

humanized_name = name.split("::").last.humanize.downcase.pluralize
localization_path = File.join(DATA_PATH, "localizations", humanized_name, "*.yml")
Expand Down

0 comments on commit c8af9f3

Please sign in to comment.