Class: ROM::Factory::Attributes::Association::ManyToOne Private

Inherits:
Core
  • Object
show all
Defined in:
lib/rom/factory/attributes/association.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from ROM::Factory::Attributes::Association::Core

Instance Method Details

#call(attrs, persist: true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rom/factory/attributes/association.rb', line 55

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_keyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


70
71
72
# File 'lib/rom/factory/attributes/association.rb', line 70

def foreign_key
  assoc.foreign_key
end