Class: PgGraph::Data::AssociationField

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

Direct Known Subclasses

MmTableField, RecordField, TableField

Instance Attribute Summary collapse

Attributes inherited from Field

#record

Attributes inherited from Node

#dimension, #type

Instance Method Summary collapse

Methods inherited from Field

#database, #guid, #name, #to_h, #uid

Methods inherited from DatabaseObject

#<=>, #database, #dot, #guid, #name, #uid

Methods inherited from Node

#data, #inspect, #to_h, #to_yaml, #value, #value_type

Constructor Details

#initialize(record, name, association) ⇒ AssociationField

Returns a new instance of AssociationField.



510
511
512
513
514
# File 'lib/pg_graph/data/data.rb', line 510

def initialize(record, name, association)
  constrain association, Association
  super(record, name, dimension: association.dimension)
  @association = association
end

Instance Attribute Details

#associationObject (readonly)

The association object



508
509
510
# File 'lib/pg_graph/data/data.rb', line 508

def association
  @association
end

Instance Method Details

#objectObject

Return the value of the association. This is either a Record, TableValue, or MmTableValue depending on the dimension of the association



518
519
520
# File 'lib/pg_graph/data/data.rb', line 518

def object()
  @object ||= Dimension.value_class(dimension).new(table, association.get_records(record))
end

#tableObject

The table of the associated record(s)



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

def table() association.that_table end