I thiink I'd do something more like this:

```
if @unsaved_values.include?(:metadata)
  # the metadata object has been reassigned
  # i.e. as object.metadata = {key => val}

  metadata_update = @values[:metadata] # original hash
  keys_to_unset = @previous_values.keys - metadata_update.keys
  keys_to_unset.each {|key| metadata_update[key] = ''}
else
  metadata_update = ...
end

metadata_update
```