Class: Ashikawa::Core::Edge

Inherits:
Document show all
Defined in:
lib/ashikawa-core/edge.rb

Overview

A certain Edge within a certain Collection

Instance Attribute Summary collapse

Attributes inherited from Document

#graph, #id, #key, #revision

Instance Method Summary collapse

Methods inherited from Document

#[], #[]=, #check_if_persisted, #delete, #refresh, #save, #to_h

Constructor Details

#initialize(_database, raw_edge, _additional_data = {}) ⇒ Edge

Initialize an Edge with the database and raw data

Examples:

Create an Edge

document = Ashikawa::Core::Edge.new(database, raw_edge)

Parameters:

  • _database (Database)
  • raw_edge (Hash)
  • _additional_data (Hash) (defaults to: {})

Options Hash (_additional_data):

  • graph (Graph)

    The graph this edge is associated with



38
39
40
41
42
# File 'lib/ashikawa-core/edge.rb', line 38

def initialize(_database, raw_edge, _additional_data = {})
  @from_id = raw_edge['_from']
  @to_id = raw_edge['_to']
  super
end

Instance Attribute Details

#from_idString (readonly)

The ID of the ‘from’ document

Examples:

Get the ID for the ‘from’ Document

document = Ashikawa::Core::Edge.new(database, raw_document)
document.from_id # => 'my_fancy_collection/2345678'

Returns:

  • (String)


18
19
20
# File 'lib/ashikawa-core/edge.rb', line 18

def from_id
  @from_id
end

#to_idString (readonly)

The ID of the ‘to’ document

Examples:

Get the ID for the ‘to’ Document

document = Ashikawa::Core::Edge.new(database, raw_document)
document.to_id # => 'my_fancy_collection/2345678'

Returns:

  • (String)


27
28
29
# File 'lib/ashikawa-core/edge.rb', line 27

def to_id
  @to_id
end