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.



50
51
52
53
54
55
56
57
58
59
60
61
62
# 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_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.



65
66
67
# File 'lib/rom/factory/attributes/association.rb', line 65

def foreign_key
  assoc.foreign_key
end