Wrong except option for nested entities
Good day. I have a problem with except option. If I use it on entity Patient like this
Patient::Entity.represent(patient, except: [testssets: [:patient]]).as_json
all works great, but I have an infinite recursion if use it on opposite entity Testsset
Testsset::Entity.represent(testsset, except: [patient: [:testssets]]).as_json
I think that there's a problem with Exposure::Base#serializeable_value. All works fine in first case because it is one-to-many relation and handled by this code
partial_output.map(&:serializable_hash)
In second case it is handled by this code (with options argument)
partial_output.serializable_hash(options)
And lately options generated for a nested entity are rewritten in Options#merge method like this
options = {except: [:testssets]}
new_options = {except: [{patient: [:testssets]}]}
options.merge(new_options)
So, now we have except fields for a nested entity such as for the parent. It seems that this code is broken and options hash should be passed in both cases. And except fields shouldn't be merged.
Indeed, it just wasn't implemented for nested except's, please contribute.