Method: Hanami::Model::Associations::HasOne#replace

Defined in:
lib/hanami/model/associations/has_one.rb

#replace(data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0



82
83
84
85
86
87
# File 'lib/hanami/model/associations/has_one.rb', line 82

def replace(data)
  repository.transaction do
    delete
    add(serialize(data))
  end
end