Class: Arango::Vertex
Instance Attribute Summary collapse
-
#collection ⇒ Object
DEFINE ===.
-
#database ⇒ Object
readonly
DEFINE ===.
-
#graph ⇒ Object
readonly
DEFINE ===.
-
#server ⇒ Object
readonly
DEFINE ===.
Attributes inherited from Document
Instance Method Summary collapse
-
#create(body: {}, waitForSync: nil) ⇒ Object
POST ==.
-
#destroy(waitForSync: nil, if_match: false) ⇒ Object
DELETE ===.
-
#from=(arg) ⇒ Object
(also: #to=, #to, #toR, #fromR)
WRONG ===.
-
#initialize(name: nil, collection:, body: {}, rev: nil, cache_name: nil) ⇒ Vertex
constructor
A new instance of Vertex.
-
#replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false) ⇒ Object
PUT ==.
-
#retrieve(if_match: false) ⇒ Object
GET ==.
-
#traversal(body: {}, sort: nil, direction: nil, minDepth: nil, visitor: nil, itemOrder: nil, strategy: nil, filter: nil, init: nil, maxIterations: nil, maxDepth: nil, uniqueness: nil, order: nil, expander: nil, edgeCollection: nil) ⇒ Object
TRAVERSAL ===.
- #update(body: {}, waitForSync: nil, if_match: false, keepNull: nil) ⇒ Object
Methods inherited from Document
#any, #edges, #from, #head, #id, #id=, #in, #name, #name=, new, #out, #rev, #rev=, #to_h
Methods included from Helper_Return
#return_delete, #return_directly?, #return_element
Methods included from Helper_Error
#satisfy_category?, #satisfy_class?, #warning_deprecated
Constructor Details
#initialize(name: nil, collection:, body: {}, rev: nil, cache_name: nil) ⇒ Vertex
Returns a new instance of Vertex.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/Vertex.rb', line 5 def initialize(name: nil, collection:, body: {}, rev: nil, cache_name: nil) assign_collection(collection) unless cache_name.nil? @cache_name = cache_name @server.cache.save(:document, cache_name, self) end body[:_key] ||= name body[:_rev] ||= rev body[:_id] ||= "#{@collection.name}/#{name}" unless name.nil? assign_attributes(body) end |
Instance Attribute Details
#collection ⇒ Object
DEFINE ===
19 20 21 |
# File 'lib/Vertex.rb', line 19 def collection @collection end |
#database ⇒ Object (readonly)
DEFINE ===
19 20 21 |
# File 'lib/Vertex.rb', line 19 def database @database end |
#graph ⇒ Object (readonly)
DEFINE ===
19 20 21 |
# File 'lib/Vertex.rb', line 19 def graph @graph end |
#server ⇒ Object (readonly)
DEFINE ===
19 20 21 |
# File 'lib/Vertex.rb', line 19 def server @server end |
Instance Method Details
#create(body: {}, waitForSync: nil) ⇒ Object
POST ==
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/Vertex.rb', line 46 def create(body: {}, waitForSync: nil) body = @body.merge(body) query = {"waitForSync": waitForSync} result = @graph.request("POST", "vertex/#{@collection.name}", body: body, query: query, key: :vertex) return result if @server.async != false body2 = result.clone body = body.merge(body2) assign_attributes(body) return return_directly?(result) ? result : self end |
#destroy(waitForSync: nil, if_match: false) ⇒ Object
DELETE ===
92 93 94 95 96 97 98 99 |
# File 'lib/Vertex.rb', line 92 def destroy(waitForSync: nil, if_match: false) query = {"waitForSync": waitForSync} headers = {} headers[:"If-Match"] = @body[:_rev] if if_match result = @graph.request("DELETE", "vertex/#{@collection.name}/#{@body[:_key]}", query: query, headers: headers) return_delete(result) end |
#from=(arg) ⇒ Object Also known as: to=, to, toR, fromR
WRONG ===
119 120 121 |
# File 'lib/Vertex.rb', line 119 def from=(arg) raise Arango::Error.new err: you_cannot_assign_from_or_to_to_a_vertex end |
#replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false) ⇒ Object
PUT ==
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/Vertex.rb', line 60 def replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false) query = { "waitForSync": waitForSync, "keepNull": keepNull } headers = {} headers[:"If-Match"] = @body[:_rev] if if_match result = @graph.request("PUT", "vertex/#{@collection.name}/#{@body[:_key]}", body: body, query: query, headers: headers, key: :vertex) return result if @server.async != false body2 = result.clone body = body.merge(body2) assign_attributes(body) return return_directly?(result) ? result : self end |
#retrieve(if_match: false) ⇒ Object
GET ==
36 37 38 39 40 41 42 |
# File 'lib/Vertex.rb', line 36 def retrieve(if_match: false) headers = {} headers[:"If-Match"] = @body[:_rev] if if_match result = @graph.request("GET", "vertex/#{@collection.name}/#{@body[:_key]}", headers: headers, key: :vertex) return_element(result) end |
#traversal(body: {}, sort: nil, direction: nil, minDepth: nil, visitor: nil, itemOrder: nil, strategy: nil, filter: nil, init: nil, maxIterations: nil, maxDepth: nil, uniqueness: nil, order: nil, expander: nil, edgeCollection: nil) ⇒ Object
TRAVERSAL ===
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/Vertex.rb', line 103 def traversal(body: {}, sort: nil, direction: nil, minDepth: nil, visitor: nil, itemOrder: nil, strategy: nil, filter: nil, init: nil, maxIterations: nil, maxDepth: nil, uniqueness: nil, order: nil, expander: nil, edgeCollection: nil) Arango::Traversal.new(body: body, sort: sort, direction: direction, minDepth: minDepth, vertex: self, visitor: visitor,itemOrder: itemOrder, strategy: strategy, filter: filter, init: init, maxIterations: maxIterations, maxDepth: maxDepth, uniqueness: uniqueness, order: order, expander: , edgeCollection: edgeCollection) end |
#update(body: {}, waitForSync: nil, if_match: false, keepNull: nil) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/Vertex.rb', line 76 def update(body: {}, waitForSync: nil, if_match: false, keepNull: nil) query = {"waitForSync": waitForSync, "keepNull": keepNull} headers = {} headers[:"If-Match"] = @body[:_rev] if if_match result = @graph.request("PATCH", "vertex/#{@collection.name}/#{@body[:_key]}", body: body, query: query, headers: headers, key: :vertex) return result if @server.async != false body2 = result.clone body = body.merge(body2) body = @body.merge(body) assign_attributes(body) return return_directly?(result) ? result : self end |