We already discussed serialization of a single object and the docs were updated with the example here.
Now, I face the situation where I need to pass some options and I noticed it is not possible due to the implementation in ResponseCreator (response.rb)
wdyt about adding this change?
# in lib/panko/response.rb
def self.serializer(data, serializer, options = {})
json serializer.new(options).serialize_to_json(data)
end
So I can then do something like this:
render(
json: Panko::Response.create do |r|
{
status: 'active',
user: r.serializer(user, UserSerializer, context: {index: true})
}
end
)
I could send a Pull Request if you think this is a good idea.
We already discussed serialization of a single object and the docs were updated with the example here.
Now, I face the situation where I need to pass some options and I noticed it is not possible due to the implementation in ResponseCreator (response.rb)
wdyt about adding this change?
So I can then do something like this:
I could send a Pull Request if you think this is a good idea.