Class: Ashikawa::Core::VertexCollection

Inherits:
Collection
  • Object
show all
Defined in:
lib/ashikawa-core/vertex_collection.rb

Overview

Note:

This is basically just a regular collection with some additional attributes and methods to ease working with collections in the graph module.

A vertex collection as it is returned from a graph

Constant Summary

Constants inherited from Collection

Collection::CONTENT_CLASS, Collection::CONTENT_TYPES

Instance Attribute Summary collapse

Attributes inherited from Collection

#content_type, #database, #id, #name, #status

Instance Method Summary collapse

Methods inherited from Collection

#[], #add_index, #create_document, #create_edge, #delete, #fetch, #figure, #index, #indices, #key_options, #length, #load, #query, #replace, #truncate, #unload, #volatile?, #wait_for_sync=, #wait_for_sync?

Constructor Details

#initialize(database, raw_collection, graph) ⇒ VertexCollection

Note:

You should not create instance manually but rather use Graph#add_vertex_collection

Create a new VertexCollection object

Parameters:

  • database (Database)

    The database the connection belongs to

  • raw_collection (Hash)

    The raw collection returned from the server

  • graph (Graph)

    The graph from which this collection was fetched

Raises:



27
28
29
30
31
32
# File 'lib/ashikawa-core/vertex_collection.rb', line 27

def initialize(database, raw_collection, graph)
  super(database, raw_collection)
  @graph = graph

  raise CollectionNotInGraphException unless @graph.has_vertex_collection?(name)
end

Instance Attribute Details

#graphGraph (readonly)

The Graph instance this VertexCollection was originally fetched from

Returns:

  • (Graph)

    The Graph instance the collection was fetched from



17
18
19
# File 'lib/ashikawa-core/vertex_collection.rb', line 17

def graph
  @graph
end

Instance Method Details

#build_content_class(data, additional_atttributes = {}) ⇒ Edge

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a new document object and passes the current graph to it

Parameters:

  • data (Hash)

    The raw data to be used to instatiate the class

  • additional_atttributes (Hash) (defaults to: {})

    Initial attributes to be passed to the document

Returns:

  • (Edge)

    The instatiated edge



40
41
42
# File 'lib/ashikawa-core/vertex_collection.rb', line 40

def build_content_class(data, additional_atttributes = {})
  Document.new(@database, data, additional_atttributes.merge(graph: graph))
end