Class: Sequel::Postgres::PropertyGraph::Generator::Edge

Inherits:
Element show all
Defined in:
lib/sequel/adapters/shared/postgres.rb

Overview

Edge is used for block passed to Create#edge, used to configure 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 Element

#key, #label

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

new

Constructor Details

#initialize(name, opts = OPTS, &block) ⇒ Edge

In addition to inherited behavior, raises an error if a block is not passed or source or destination is not called in the block.



397
398
399
400
401
402
403
# File 'lib/sequel/adapters/shared/postgres.rb', line 397

def initialize(name, opts=OPTS, &block)
  super

  unless @source && @destination
    raise Error, "source and/or destination not defined for property graph edge"
  end
end

Instance Method Details

#dataObject



405
406
407
# File 'lib/sequel/adapters/shared/postgres.rb', line 405

def data
  Data.new(@name, @key, @labels, @source, @destination).freeze
end

#destination(name, &block) ⇒ Object

Specify the destination for the edge, with block evaluted by Target.

Raises:



416
417
418
419
# File 'lib/sequel/adapters/shared/postgres.rb', line 416

def destination(name, &block)
  raise Error, "cannot specify multiple destinations for a property graph edge" if @destination
  @destination = Target.new(name, &block)
end

#source(name, &block) ⇒ Object

Specify the source for the edge, with block evaluted by Target.

Raises:



410
411
412
413
# File 'lib/sequel/adapters/shared/postgres.rb', line 410

def source(name, &block)
  raise Error, "cannot specify multiple sources for a property graph edge" if @source
  @source = Target.new(name, &block)
end