Class: PgGraph::Data::Field

Inherits:
DatabaseObject show all
Defined in:
lib/pg_graph/data/data.rb

Direct Known Subclasses

AssociationField, Column

Instance Attribute Summary collapse

Attributes inherited from Node

#dimension, #type

Instance Method Summary collapse

Methods inherited from DatabaseObject

#<=>, #dot

Methods inherited from Node

#data, #inspect, #object, #to_yaml, #value, #value_type

Constructor Details

#initialize(record, name, **opts) ⇒ Field

Returns a new instance of Field.



458
459
460
461
462
463
# File 'lib/pg_graph/data/data.rb', line 458

def initialize(record, name, **opts)
  constrain record, Record
  constrain name, String, Symbol
  @record = record # has to go before super
  super(record.type[name.to_s], **opts)
end

Instance Attribute Details

#recordObject (readonly)

Record of field



456
457
458
# File 'lib/pg_graph/data/data.rb', line 456

def record
  @record
end

Instance Method Details

#databaseObject

Redefine DatabaseObject#database



453
# File 'lib/pg_graph/data/data.rb', line 453

def database() record.database end

#guidObject

Redefine #uid



447
# File 'lib/pg_graph/data/data.rb', line 447

def guid() "#{record.guid}.#{name}" end

#nameObject

Redefine #name to return a Symbol



450
# File 'lib/pg_graph/data/data.rb', line 450

def name() super.to_sym end

#to_hObject



465
# File 'lib/pg_graph/data/data.rb', line 465

def to_h() { name: value } end

#uidObject

Redefine #uid



444
# File 'lib/pg_graph/data/data.rb', line 444

def uid() "#{record.uid}.#{name}" end