Class: ROM::Factory::Attributes::Association::OneToMany Private
- 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.
Direct Known Subclasses
Instance Method Summary collapse
- #call(attrs = EMPTY_HASH, parent, persist: true) ⇒ Object private
- #count ⇒ Object private
- #dependency?(rel) ⇒ Boolean private
Constructor Details
This class inherits a constructor from ROM::Factory::Attributes::Association::Core
Instance Method Details
#call(attrs = EMPTY_HASH, parent, 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.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rom/factory/attributes/association.rb', line 70 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 ⇒ 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.
93 94 95 |
# File 'lib/rom/factory/attributes/association.rb', line 93 def count .fetch(:count) end |
#dependency?(rel) ⇒ Boolean
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.
88 89 90 |
# File 'lib/rom/factory/attributes/association.rb', line 88 def dependency?(rel) assoc.source == rel end |