lib/hanami/model/associations/has_many.rb in hanami-model-1.3.2 vs lib/hanami/model/associations/has_many.rb in hanami-model-1.3.3

- old
+ new

@@ -1,15 +1,17 @@ -require 'hanami/model/types' +# frozen_string_literal: true +require "hanami/model/types" + module Hanami module Model module Associations # One-To-Many association # # @since 0.7.0 # @api private - class HasMany # rubocop:disable Metrics/ClassLength + class HasMany # @since 0.7.0 # @api private def self.schema_type(entity) type = Sql::Types::Schema::AssociationType.new(entity) Types::Strict::Array.member(type) @@ -49,21 +51,21 @@ # @since 0.7.0 # @api private def create(data) entity.new(command(:create, aggregate(target), mapper: nil, use: [:timestamps]) .call(serialize(data))) - rescue => e - raise Hanami::Model::Error.for(e) + rescue => exception + raise Hanami::Model::Error.for(exception) end # @since 0.7.0 # @api private def add(data) command(:create, relation(target), use: [:timestamps]) .call(associate(serialize(data))) - rescue => e - raise Hanami::Model::Error.for(e) + rescue => exception + raise Hanami::Model::Error.for(exception) end # @since 0.7.0 # @api private def remove(id) @@ -111,11 +113,11 @@ private # @since 0.7.0 # @api private def command(target, relation, options = {}) - repository.command(target => relation, **options) + repository.command(target, relation, options) end # @since 0.7.0 # @api private def entity @@ -149,10 +151,10 @@ end # @since 0.7.0 # @api private def unassociate - { foreign_key => nil } + {foreign_key => nil} end # @since 0.7.0 # @api private def container