Class: Graphoid::EmbedsOne
- Defined in:
- lib/graphoid/operators/inherited/embeds_one.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, value, _) ⇒ Object
5 6 7 8 |
# File 'lib/graphoid/operators/inherited/embeds_one.rb', line 5 def create(parent, value, _) attrs = Attribute.correct(klass, value) parent.send(:"#{name}=", attrs) end |
#exec(_scope, value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/graphoid/operators/inherited/embeds_one.rb', line 10 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) _hash.merge!(parsed) end _hash end |