-
Notifications
You must be signed in to change notification settings - Fork 10
Feature: Member Name Styles #12
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
base: master
Are you sure you want to change the base?
Feature: Member Name Styles #12
Conversation
Thanks for pitching in @vovimayhem! We should absolutely be supporting different key formatting. Wanted to get your thoughts on an alternate tact here. The two things I'm looking for:
I think we can get this without too much trouble. Under the hood, we essentially say Instead, what about allowing users to set a "default comparison" proc instead of relying on that default? This way we'd avoid the JsonapiSpecHelpers::Payload.register(:person) do
self.default_comparison = ->(key, record) { record.send(key.underscore) }
end The issue here is we would probably need a way to globally set this as well as override. Another option would be to set our default proc to use Thoughts? |
|
An alternate idea (although I'm going as far as change the current DSL) to use a 'test/assertion' language for the payload DSL:
This way, the user is expected to put the exact attribute he/she is expecting to find in the payload. |
I think these are good ideas for maybe a future release but I'd like to keep backwards-compatibility for now. Seems like the simplest thing we could do to solve the issue without any developer-facing changes would be changing this line to: prc ||= lambda do |record|
# alternatively, copy the method from activesupport and add to this repo
name = name.underscore if name.respond_to?(:underscore)
record.send(name)
end Would that work for you? |
What does this PR do?
Addresses #11 by implementing the following changes:
member_name_style
, which configures the style used for member names:member_name_style
, which configures the above-mentioned styles on all members.