Class: PgGraph::Data::LinkAssociation

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

Instance Attribute Summary collapse

Attributes inherited from Association

#dimension, #that_field, #that_table, #this_field, #this_table

Instance Method Summary collapse

Methods inherited from Association

#get, #get_record, #query

Constructor Details

#initialize(dimension, this_table, that_table, link_table, this_field, this_link_field, that_link_field, that_field) ⇒ LinkAssociation

Returns a new instance of LinkAssociation.



66
67
68
69
70
71
72
73
# File 'lib/pg_graph/data/association.rb', line 66

def initialize(
    dimension,
    this_table, that_table, link_table, 
    this_field, this_link_field, that_link_field, that_field)
  super(dimension, this_table, that_table, this_field, that_field)
  @this_association = Association.new(2, this_table, link_table, this_field, this_link_field)
  @that_association = Association.new(1, link_table, that_table, that_link_field, that_field)
end

Instance Attribute Details

#that_associationObject (readonly)

From the link table to ‘that’ table. RecordAssociation object



55
56
57
# File 'lib/pg_graph/data/association.rb', line 55

def that_association
  @that_association
end

#this_associationObject (readonly)

From this table to the link table. TableAssociation object



52
53
54
# File 'lib/pg_graph/data/association.rb', line 52

def this_association
  @this_association
end

Instance Method Details

#get_records(record) ⇒ Object

Note that records are not unique for MmTableAssociation but for NmTableAssociation objects



77
78
79
# File 'lib/pg_graph/data/association.rb', line 77

def get_records(record)
  @this_association.get(record).map { |link_record| @that_association.get(link_record) }
end

The link table in the N:M relation



58
# File 'lib/pg_graph/data/association.rb', line 58

def link_table() this_association.that_table end

The field in the link table that links to that record



64
# File 'lib/pg_graph/data/association.rb', line 64

def that_link_field() that_association.this_field end

The field in the link table that links to this record



61
# File 'lib/pg_graph/data/association.rb', line 61

def this_link_field() this_association.that_field end