class Arango::Edge

Attributes

collection[R]

DEFINE ===

database[R]

DEFINE ===

graph[R]

DEFINE ===

server[R]

DEFINE ===

Public Class Methods

new(name: nil, collection:, body: {}, rev: nil, from: nil, to: nil) click to toggle source
# File lib/Edge.rb, line 5
def initialize(name: nil, collection:, body: {}, rev: nil, from: nil,
  to: nil)
  assign_collection(collection)
  body[:_key]  ||= name
  body[:_rev]  ||= rev
  body[:_from] ||= from
  body[:_to]   ||= to
  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/Edge.rb, line 20
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/Edge.rb, line 45
def create(body: {}, waitForSync: nil)
  body = @body.merge(body)
  query = {
    "waitForSync": waitForSync,
    "_from":      @body[:_from],
    "_to":        @body[:_to]
  }
  result = @graph.request("POST", "edge/#{@collection.name}", body: body,
    query: query, key: :edge)
  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/Edge.rb, line 95
def destroy(waitForSync: nil, if_match: false)
  query = {"waitForSync": waitForSync}
  headers = {}
  headers[:"If-Match"] = @body[:_rev] if if_match
  result = @graph.request("DELETE", "edge/#{@collection.name}/#{@body[:_key]}",
    query: query, headers: headers)
  return_delete(result)
end
replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false) click to toggle source

PUT ==

# File lib/Edge.rb, line 63
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", "edge/#{@collection.name}/#{@body[:_key]}",
    body: body, query: query, headers: headers, key: :edge)
  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/Edge.rb, line 35
def retrieve(if_match: false)
  headers = {}
  headers[:"If-Match"] = @body[:_rev] if if_match
  result = @graph.request("GET", "edge/#{@collection.name}/#{@body[:_key]}",
    headers: headers, key: :edge)
  return_element(result)
end
update(body: {}, waitForSync: nil, if_match: false) click to toggle source
# File lib/Edge.rb, line 79
def update(body: {}, waitForSync: nil, if_match: false)
  query = {"waitForSync": waitForSync}
  headers = {}
  headers[:"If-Match"] = @body[:_rev] if if_match
  result = @graph.request("PATCH", "edge/#{@collection.name}/#{@body[:_key]}",
    body: body, query: query, headers: headers, key: :edge)
  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