class ROM::Factory::Attributes::Association::OneToMany

@api private

Public Instance Methods

call(attrs = EMPTY_HASH, parent, persist: true) click to toggle source

@api private

# File lib/rom/factory/attributes/association.rb, line 73
def call(attrs = EMPTY_HASH, parent, persist: true)
  return if attrs.key?(name)

  structs = Array.new(count).map do
    # hash which contains the foreign key info, i.e: { user_id: 1 }
    association_hash = assoc.associate(attrs, parent)

    if persist
      builder.persistable.create(*traits, association_hash)
    else
      builder.struct(*traits, attrs.merge(association_hash))
    end
  end

  { name => structs }
end
count() click to toggle source

@api private

# File lib/rom/factory/attributes/association.rb, line 96
def count
  options.fetch(:count)
end
dependency?(rel) click to toggle source

@api private

# File lib/rom/factory/attributes/association.rb, line 91
def dependency?(rel)
  assoc.source == rel
end