Sha256: 031ccfc89850481e81d67327a4c9fca65cce9f82263f129fc9066c82cedef46f

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 Bytes

Contents

# frozen_string_literal: true

require 'clowne/ext/yield_self_then'

using Clowne::Ext::YieldSelfThen

module Clowne
  module Adapters # :nodoc: all
    class Sequel
      module Associations
        class OneToMany < Base
          def call(record)
            clones =
              with_scope.map do |child|
                clone_one(child).tap do |child_clone|
                  child_clone[:"#{reflection[:key]}"] = nil
                end.then(&method(:record_wrapper))
              end

            record_wrapper(record).remember_assoc(:"#{association_name}_attributes", clones)

            record
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clowne-1.1.0 lib/clowne/adapters/sequel/associations/one_to_many.rb
clowne-1.0.0 lib/clowne/adapters/sequel/associations/one_to_many.rb