Class: Sequel::Postgres::PropertyGraph::Generator::Create

Inherits:
Sequel::Postgres::PropertyGraph::Generator show all
Defined in:
lib/sequel/adapters/shared/postgres.rb

Overview

Create is used to evaluate the block given to DatabaseMethods#create_property_graph, used to specify the vertices and edges in the property graph.

Defined Under Namespace

Classes: Data

Constant Summary

Constants inherited from Sequel::Postgres::PropertyGraph::Generator

Vertex

Instance Method Summary collapse

Methods inherited from Sequel::Postgres::PropertyGraph::Generator

new

Constructor Details

#initialize(&block) ⇒ Create

Returns a new instance of Create.



427
428
429
430
431
432
433
434
# File 'lib/sequel/adapters/shared/postgres.rb', line 427

def initialize(&block)
  @vertices = []
  @edges = []
  instance_exec(&block)
  @vertices.freeze
  @edges.freeze
  freeze
end

Instance Method Details

#dataObject



436
437
438
# File 'lib/sequel/adapters/shared/postgres.rb', line 436

def data
  Data.new(@vertices, @edges).freeze
end

#edge(name, opts = OPTS, &block) ⇒ Object

Adds an edge to the property graph, with the block evaluted by Edge.



446
447
448
# File 'lib/sequel/adapters/shared/postgres.rb', line 446

def edge(name, opts=OPTS, &block)
  @edges << Edge.new(name, opts, &block)
end

#vertex(name, opts = OPTS, &block) ⇒ Object

Adds a vertex to the property graph, with the block evaluted by Vertex.



441
442
443
# File 'lib/sequel/adapters/shared/postgres.rb', line 441

def vertex(name, opts=OPTS, &block)
  @vertices << Vertex.new(name, opts, &block)
end