Module: Arango::Graph::EdgeAccess

Defined in:
lib/arango/graph/definition.rb

Overview

Arango Graph EdgeAccess

Instance Method Summary collapse

Instance Method Details

#add_edge_definition(collection:, from:, to:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/arango/graph/definition.rb', line 21

def add_edge_definition(collection:, from:, to:)
  satisfy_module_or_string?(collection, Arango::DocumentCollection::Mixin)
  satisfy_module_or_string?(from, Arango::Document::Mixin)
  satisfy_module_or_string?(to, Arango::Document::Mixin)
  from = [from] unless from.is_a?(Array)
  to = [to] unless to.is_a?(Array)
  body = {}
  body[:collection] = collection.is_a?(String) ? collection : collection.name
  body[:from] = from.map{|f| f.is_a?(String) ? f : f.name }
  body[:to] = to.map{|t| t.is_a?(String) ? t : t.name }
  result = request("POST", "edge", body: body, key: :graph)
  return_element(result)
end

#edge_collectionObject



6
7
8
# File 'lib/arango/graph/definition.rb', line 6

def edge_collection

end

#edge_collectionsObject



10
11
12
13
14
15
# File 'lib/arango/graph/definition.rb', line 10

def edge_collections
  result = request("GET", "edge", key: :collections)
  return result if @database.server.async != false
  return result if return_directly?(result)
  result.map{|r| Arango::DocumentCollection.new(database: @database, name: r, type: :edge)}
end

#edge_definitionsObject



17
18
19
# File 'lib/arango/graph/definition.rb', line 17

def edge_definitions

end

#remove_edge_definition(collection:, dropCollection: nil) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/arango/graph/definition.rb', line 49

def remove_edge_definition(collection:, dropCollection: nil)
  satisfy_class?(collection, [String, Arango::DocumentCollection])
  query = {dropCollection: dropCollection}
  collection = collection.is_a?(String) ? collection : collection.name
  result = request("DELETE", "edge/#{collection}", query: query, key: :graph)
  return_element(result)
end

#replace_edge_definition(collection:, from:, to:) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/arango/graph/definition.rb', line 35

def replace_edge_definition(collection:, from:, to:)
  satisfy_class?(collection, [String, Arango::DocumentCollection])
  satisfy_class?(from, [String, Arango::DocumentCollection], true)
  satisfy_class?(to, [String, Arango::DocumentCollection], true)
  from = [from] unless from.is_a?(Array)
  to = [to] unless to.is_a?(Array)
  body = {}
  body[:collection] = collection.is_a?(String) ? collection : collection.name
  body[:from] = from.map{|f| f.is_a?(String) ? f : f.name }
  body[:to] = to.map{|t| t.is_a?(String) ? t : t.name }
  result = request("PUT", "edge/#{body[:collection]}", body: body, key: :graph)
  return_element(result)
end