Method: Hanami::Model::Associations::HasOne#create

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

#create(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



54
55
56
57
58
59
60
# File 'lib/hanami/model/associations/has_one.rb', line 54

def create(data)
  entity.new(
    command(:create, aggregate(target), mapper: nil).call(serialize(data))
  )
rescue => exception
  raise Hanami::Model::Error.for(exception)
end