Open wujibear opened 1 year ago
Actually, this only seems to work if I put the method in the serializer that is serializing. Doesn't seem to get inherited for some reason, investigating that.
K. Fixed that, now it checks for parent definitions if no proc or existing instance var is supplied. This lets you write a pattern you can inherit from, but any serializer can explicitly set its own transform method for its attributes
Thanks for the PR. This seems reasonable. I know JS tends to lean towards snake-cased variables and having the JSON the same way can make things simpler with object deconstruction.
I would want to see some specs to cover this new functionality before I would merge it though.
Any other thoughts on method naming, or implementation though?
Added a spec and docs
@adamcrown got those specs for you
@adamcrown Any other thoughts? Would you want to merge this?
I was asking about being able to transform keys to something like camelcase and tried this out. Unsure of your needs for contributions, but let me know what you think of the idea.
With this I can now do the following:
Serialized data will look like:
I then have all my serializers inherit from this one and now all my keys will be transformed to lower camelcase
See: https://github.com/codenoble/cache-crispies/issues/52