Class: Graphoid::HasMany

Inherits:
Relation show all
Defined in:
lib/graphoid/operators/inherited/has_many.rb

Instance Attribute Summary

Attributes inherited from Relation

#inverse_name, #klass, #name, #type

Instance Method Summary collapse

Methods inherited from Relation

#belongs?, #embedded?, #initialize, #many?, #many_to_many?, #one?, #precreate, #relation?, relations_of, #resolve

Constructor Details

This class inherits a constructor from Graphoid::Relation

Instance Method Details

#create(parent, values, grapho) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/graphoid/operators/inherited/has_many.rb', line 5

def create(parent, values, grapho)
  values.each do |value|
    attributes = Attribute.correct(klass, value)
    attributes[:"#{grapho.name}_id"] = parent.id
    klass.create!(attributes)
  end
end