On Sunday, May 3, 2015 at 5:17:58 PM UTC-7, Jon Mattingly wrote:
>
> My use case is that I'm using Grape API with Sequel. I have it set to 
> automatically convert returned values to json for me, so the 
> to_json(:include) doesn't work for me unless I were to either disable the 
> automatic json conversion for that route (not sure if possible), or call 
> to_json and then parse the json back to a hash, which is really no better 
> than just mapping the relation myself.
>

If Grape is just converting returned values to json, instead of giving it a 
hash, why don't you give it the model object (which it will call to_json 
on)?  You could change the class-level to_json defaults to 
:include=>:relation, or if you want to handle this on an 
instance-by-instance basis, we could add support in json_serializer for 
storing to_json options at the instance level, and have a later to_json 
call use them.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to