module Arcade class Edge < Base # schema schema.strict # -- throws an error if specified keys are missing attribute :in, Types::Rid attribute :out, Types::Rid def accepted_methods super + [ :vertices, :in, :out, :inV, :outV ] end # # Add Contrains to the edge # CREATE INDEX Watched_out_in ON e if e.message =~ /Duplicated key\s+.+\sfound on index/ if e.args.keys.first == :exceptionArgs # return the previously assigned edge e.args[:exceptionArgs].split('|').last.load_rid else raise end else raise end end def delete db.execute{ "delete edge #{ rid }" }.select_result end ## gets the adjacent Vertex def inV query( projection: "inV()").query.select_result end def outV query( projection: "outV()").query.select_result end def vertices in_or_out = nil case in_or_out when :in inV when :out outV else [inV, outV] end end alias bothV vertices def to_human "<#{self.class.to_s.snake_case}[#{rid}] :.: #{ out }->#{invariant_attributes}->#{ attributes[:in] }>" end end end