lib/hanami/model/associations/has_one.rb in hanami-model-1.3.2 vs lib/hanami/model/associations/has_one.rb in hanami-model-1.3.3
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require "hanami/utils/hash"
module Hanami
module Model
module Associations
@@ -51,32 +53,32 @@
def create(data)
entity.new(
command(:create, aggregate(target), mapper: nil).call(serialize(data))
)
- rescue => e
- raise Hanami::Model::Error.for(e)
+ rescue => exception
+ raise Hanami::Model::Error.for(exception)
end
def add(data)
command(:create, relation(target), mapper: nil).call(associate(serialize(data)))
- rescue => e
- raise Hanami::Model::Error.for(e)
+ rescue => exception
+ raise Hanami::Model::Error.for(exception)
end
def update(data)
command(:update, relation(target), mapper: nil)
.by_pk(
one.public_send(relation(target).primary_key)
).call(serialize(data))
- rescue => e
- raise Hanami::Model::Error.for(e)
+ rescue => exception
+ raise Hanami::Model::Error.for(exception)
end
def delete
scope.delete
end
- alias remove delete
+ alias_method :remove, :delete
def replace(data)
repository.transaction do
delete
add(serialize(data))