class Arango::Vertex

Attributes

collection[R]

DEFINE ===

database[R]

DEFINE ===

graph[R]

DEFINE ===

server[R]

DEFINE ===

Public Class Methods

new(name: nil, collection:, body: {}, rev: nil, cache_name: nil) click to toggle source
# 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

Public Instance Methods

assign_collection(collection)
Alias for: collection=
collection=(collection) click to toggle source
# File lib/Vertex.rb, line 21
def collection=(collection)
  satisfy_class?(collection, [Arango::Collection])
  if collection.graph.nil?
    raise Arango::Error.new err: :collection_does_not_have_a_graph, data:
      {"name_collection": collection.name, "graph": nil}
  end
  @collection = collection
  @graph = @collection.graph
  @database = @collection.database
  @server = @database.server
end
Also aliased as: assign_collection
create(body: {}, waitForSync: nil) click to toggle source

POST ==

# 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) click to toggle source

DELETE ===

# 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) click to toggle source

WRONG ===

# File lib/Vertex.rb, line 119
def from=(arg)
  raise Arango::Error.new err: you_cannot_assign_from_or_to_to_a_vertex
end
Also aliased as: to=, to, toR, fromR
fromR(arg)
Alias for: from=
replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false) click to toggle source

PUT ==

# 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) click to toggle source

GET ==

# 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
to(arg)
Alias for: from=
to=(arg)
Alias for: from=
toR(arg)
Alias for: from=
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) click to toggle source

TRAVERSAL ===

# 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: expander, edgeCollection: edgeCollection)
end
update(body: {}, waitForSync: nil, if_match: false, keepNull: nil) click to toggle source
# 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