Class: PgGraph::Type::TableColumn

Inherits:
Column show all
Defined in:
lib/pg_graph/type/type.rb,
lib/pg_graph/type/dump_type.rb

Direct Known Subclasses

MmTableColumn

Instance Attribute Summary collapse

Attributes inherited from Column

#postgres_column

Attributes inherited from Field

#type

Instance Method Summary collapse

Methods inherited from Column

#dump, #generated?, #identity?, #kind?, #nullable?, #primary_key?, #readonly?, #reference?, #unique?

Methods included from TableObject

#record_type, #table, #table_type

Methods inherited from Field

#identifier, #schema_identifier

Methods inherited from Node

#dump, #guid, #identifier, #inspect, #inspect_inner, #schema_identifier

Constructor Details

#initialize(record_type, name, type, this_link_column, that_link_column, **opts) ⇒ TableColumn

Returns a new instance of TableColumn.



578
579
580
581
582
583
584
# File 'lib/pg_graph/type/type.rb', line 578

def initialize(record_type, name, type, this_link_column, that_link_column, **opts)
  constrain record_type, RecordType
  constrain type, TableType
  super(record_type, name, nil, type, **opts)
  @this_link_column = this_link_column
  @that_link_column = that_link_column
end

Instance Attribute Details

Postgres column in the subject table that directly or indirectly links to the embedding record. This is typically the ‘<this-table>_id’ column of that table in 1:N relations



574
575
576
# File 'lib/pg_graph/type/type.rb', line 574

def that_link_column
  @that_link_column
end

Postgres column in the embedding record that links (directly or indirectly) to the subject table. This is typically the id column



569
570
571
# File 'lib/pg_graph/type/type.rb', line 569

def this_link_column
  @this_link_column
end

Instance Method Details

#dot_lookup(key) ⇒ Object



586
# File 'lib/pg_graph/type/type.rb', line 586

def dot_lookup(key) type[key] end

#dump_typeObject



56
57
58
# File 'lib/pg_graph/type/dump_type.rb', line 56

def dump_type
  print " (#{this_link_column} -> #{type.table.name}.#{that_link_column}) (TableColumn)"
end