You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: related_node.rb
    path of file: ./repos/activegraph/lib/active_graph/relationship
    
    the code of the file until where you have to start completion: module ActiveGr
    
    def loaded
      fail UnsetRelatedNodeError, 'Node not set, cannot load' if @node.nil?
      @node = if @node.respond_to?(:neo_id)
                @node
              else
                ActiveGraph::Base.new_query.match(:n).where(n: {neo_id: @node}).pluck(:n).first
              end