class Graphoid::BelongsTo

Public Instance Methods

exec(_, value) click to toggle source
# File lib/graphoid/operators/inherited/belongs_to.rb, line 11
def exec(_, value)
  ids = Graphoid::Queries::Processor.execute(klass, value).to_a.map(&:id)
  attribute = Attribute.new(name: "#{name.underscore}_id", type: nil)
  Graphoid.driver.parse(attribute, ids, 'in')
end
precreate(value) click to toggle source
# File lib/graphoid/operators/inherited/belongs_to.rb, line 5
def precreate(value)
  sanitized = Attribute.correct(klass, value)
  foreign_id = klass.create!(sanitized).id
  { :"#{name}_id" => foreign_id }
end