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) }
endThe 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)
endWould 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.