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

Fix overwriting existing plurals, singulars, and irregulars #18

Merged
merged 2 commits into from
Jul 14, 2021

Conversation

matthewmcgarvey
Copy link
Member

@matthewmcgarvey matthewmcgarvey commented Jul 13, 2021

Fixes #17

When you call .each on a Hash, there is an implicit ordering of how it goes through the items. Wordsmith was relying on the first match in that to be the most specific. Also, it prioritized existing pluralizations/singularizations over adding new ones.

Wordsmith::Inflector.inflections.plural("person", "people")
Wordsmith::Inflector.inflections.plural("person", "persons")
Wordsmith::Inflector.pluralize("person") # you'd expect "persons" but it was "people"

This change updates the behavior of wordsmith to prioritize later additions for matching words.

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@matthewmcgarvey matthewmcgarvey merged commit c537f33 into master Jul 14, 2021
@matthewmcgarvey matthewmcgarvey deleted the fix-overwriting branch July 14, 2021 01:54
@stephendolan
Copy link
Member

stephendolan commented Jul 14, 2021

My hero! Cc @btihen in case you'd be willing to test this out for your use case we worked through with our less elegant "salt the earth" approach.

If you wanted to and need help setting that up, I'd be happy to walk through it together!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make overriding easier
3 participants