Class: Arcade::Edge

Inherits:
Base
  • Object
show all
Defined in:
lib/model/edge.rb

Direct Known Subclasses

Basicedge

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, all, count, create_type, database_name, drop_type, find, first, insert, #insert_document, #inspect, #invariant_attributes, last, #method_missing, not_permitted, properties, #query, query, #refresh, #rid?, timestamps, #to_html, #to_json, #to_or, update, #update, update!, #update_embedded, #update_list, #update_map, upsert, where

Methods included from Support::Sql

#compose_where, #generate_sql_list

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Arcade::Base

Class Method Details

.create(from:, to:, **attr) ⇒ Object

Add Contrains to the edge CREATE INDEX Watched_out_in ON <edge type« (‘@out`, `@in`) UNIQUE



14
15
16
# File 'lib/model/edge.rb', line 14

def self.create  from:, to:, **attr
    db.create_edge  database_name, from: from, to: to, **attr
end

Instance Method Details

#accepted_methodsObject



7
8
9
# File 'lib/model/edge.rb', line 7

def accepted_methods
  super + [ :vertices, :in, :out, :inV, :outV ]
end

#deleteObject



18
19
20
# File 'lib/model/edge.rb', line 18

def delete
  db.execute{  "delete edge #{ rid }" }.select_result
end

#inVObject

gets the adjacent Vertex



22
23
24
# File 'lib/model/edge.rb', line 22

def inV
  query( projection: "inV()").query.select_result
end

#outVObject



25
26
27
# File 'lib/model/edge.rb', line 25

def outV
  query( projection: "outV()").query.select_result
end

#to_humanObject



42
43
44
# File 'lib/model/edge.rb', line 42

def to_human
  "<#{self.class.to_s.snake_case}[#{rid}] :.: #{ out }->#{invariant_attributes}->#{ attributes[:in] }>"
end

#vertices(in_or_out = nil) ⇒ Object Also known as: bothV



28
29
30
31
32
33
34
35
36
37
# File 'lib/model/edge.rb', line 28

def vertices in_or_out = nil
  case in_or_out
  when :in
    inV
  when :out
    outV
  else
    [inV, outV]
  end
end