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

Add a config option to disable or change pluralization #63

Merged
merged 2 commits into from Nov 7, 2016

Conversation

wolfgang42
Copy link
Contributor

I have an API which does not pluralize the names of its models. This PR adds an option to disable pluralization so I can use Devour as my client, and also custom pluralization for other users who might have different pluralization requirements not covered by the default pluralize.

Incidental to this change is an update to an error message. The original problem was that the error message did not reflect the expected pluralization, leading to the confusing error The JSON API response had a type of "Products" but Devour expected the type to be "Products". While I was at it I also changed the message to reflect the actual underlying problem, modifying the code originally added by #10 as the response model was no longer needed for the error message.

Wolfgang Faust added 2 commits November 1, 2016 17:13
devour-js#10 added this error message, but did not consider other
circumstances under which this condition might occur.
@spiderbites
Copy link
Contributor

Hi @wolfgang42 thanks for this PR!

Just wondering if you looked at using the collectionPath option when defining your models, I think this would have been a way for force non-pluralized model names, although with a large number of models this is definitely a cleaner solution.

@wolfgang42
Copy link
Contributor Author

@spiderbites The problem with that is Devour also tries to singularize the name of the model, so if your models are plural it can't find them. I could try to keep track of which bits needed to be singular and which bits needed to be plural, but it was altogether simpler to turn off pluralization entirely so I can use the name that the API gives it everywhere without having to worry about conversions.

@spiderbites spiderbites merged commit 6242c7f into devour-js:master Nov 7, 2016
@wolfgang42 wolfgang42 deleted the no-pluralize branch November 21, 2016 23:50
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.

None yet

2 participants