-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Expected behavior vs actual behavior
So, we want to have the key object
to be present in the response of the serializer. However, since object is defined as attr_accessor :object
.
It's hard to override, since we want to include the object
key in the response. Is there any way to redefine the object
as another serializer attribute, something like record
?.
We can provide an option to override the key name, which then defaults to object
?.
We can change the constructor to accept another argument, namely the object_name
?.
This then can be done as follows
def initialize(object, options = {})
if options[:object_name]
self.class.instance_eval do
attr_accessor options[:object_name]
end
end
end
What do you guys think?
Metadata
Metadata
Assignees
Labels
No labels