class ROM::Factory::Attributes::Association::ManyToOne

@api private

Public Instance Methods

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

@api private

# File lib/rom/factory/attributes/association.rb, line 50
def call(attrs, persist: true)
  if attrs.key?(name) && !attrs[foreign_key]
    assoc.associate(attrs, attrs[name])
  elsif !attrs[foreign_key]
    struct = if persist
               builder.persistable.create(*traits)
             else
               builder.struct(*traits)
             end
    tuple = { name => struct }
    assoc.associate(tuple, struct)
  end
end
foreign_key() click to toggle source

@api private

# File lib/rom/factory/attributes/association.rb, line 65
def foreign_key
  assoc.foreign_key
end