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 = EMPTY_HASH) ⇒ 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.



44
45
46
47
48
49
50
51
52
53
# File 'lib/rom/factory/attributes/association.rb', line 44

def call(attrs = EMPTY_HASH)
  if attrs.key?(name) && !attrs[foreign_key]
    assoc.associate(attrs, attrs[name])
  elsif !attrs[foreign_key]
    struct = builder.persistable.create
    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.



56
57
58
# File 'lib/rom/factory/attributes/association.rb', line 56

def foreign_key
  assoc.foreign_key
end