Class: Sequel::Postgres::PropertyGraph::Generator::Target

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

Overview

Target is used for the block passed to Edge#source and Edge#destination, used to configure the source and destination of property graph edges.

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(name, &block) ⇒ Target

name specifies the name of the source or destination.



350
351
352
353
354
355
356
# File 'lib/sequel/adapters/shared/postgres.rb', line 350

def initialize(name, &block)
  @name = name
  @key = nil
  @references = nil
  instance_exec(&block) if block
  freeze
end

Instance Method Details

#dataObject



358
359
360
# File 'lib/sequel/adapters/shared/postgres.rb', line 358

def data
  Data.new(@name, @key, @references).freeze
end

#key(keys) ⇒ Object

Set the column(s) to use for the KEY clause, which are the columns in the edge table that reference columns in the source or destination. Should be combined with #references to specify the columns being referenced.

key(:vertex_id)
# KEY (vertex_id)

key([:vertex_id1, :vertex_id2])
# KEY (vertex_id1, vertex_id2)


372
373
374
# File 'lib/sequel/adapters/shared/postgres.rb', line 372

def key(keys)
  @key = Array(keys)
end

#references(refs) ⇒ Object

Set the column(s) to use for the REFERENCES clause, which are the columns in the source or destination table that are referenced by the edge table. Should be combined with #key to specify the columns doing the referencing.

references(:id)
# REFERENCES (id)

references([:id1, :id2])
# REFERENCES (id1, id2)


385
386
387
# File 'lib/sequel/adapters/shared/postgres.rb', line 385

def references(refs)
  @references = Array(refs)
end