Class: Graphoid::EmbedsMany
- Defined in:
- lib/graphoid/operators/inherited/embeds_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, _) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/graphoid/operators/inherited/embeds_many.rb', line 5 def create(parent, values, _) values.each do |value| attributes = Attribute.correct(klass, value) parent.send(:"#{name}").create!(attributes) end end |
#exec(_scope, value) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/graphoid/operators/inherited/embeds_many.rb', line 12 def exec(_scope, value) _hash = {} value.each do |key, _value| operation = Operation.new(klass, key, _value) parsed = Graphoid.driver.parse(operation.operand, operation.value, operation.operator, klass.to_s.underscore.pluralize) _hash.merge!(parsed) end _hash end |