class Graphoid::HasOne
Public Instance Methods
create(parent, value, grapho)
click to toggle source
# File lib/graphoid/operators/inherited/has_one.rb, line 5 def create(parent, value, grapho) attributes = Attribute.correct(klass, value) attributes[:"#{grapho.name}_id"] = parent.id klass.create!(attributes) end
exec(scope, value)
click to toggle source
# File lib/graphoid/operators/inherited/has_one.rb, line 11 def exec(scope, value) field_name = inverse_name || scope.name.underscore ids = Graphoid::Queries::Processor.execute(klass, value).to_a.map(&"#{field_name}_id".to_sym) attribute = Attribute.new(name: 'id', type: nil) Graphoid.driver.parse(attribute, ids, 'in') end