Class: G2R::RDBMS::JoinTable
- Defined in:
- lib/graph2relational/rdbms-join-table.rb
Instance Method Summary collapse
-
#columns ⇒ Object
Additionally return the source and target column ids plus all defined columns.
-
#initialize(source_table, relationship, target_table) ⇒ JoinTable
constructor
A new instance of JoinTable.
- #source_column ⇒ Object
-
#source_table ⇒ Object
ACESSORS ==========================================================================.
- #target_column ⇒ Object
- #target_table ⇒ Object
Methods inherited from Table
#==, #add_columns, #add_data, #data, #name
Constructor Details
#initialize(source_table, relationship, target_table) ⇒ JoinTable
Returns a new instance of JoinTable.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/graph2relational/rdbms-join-table.rb', line 6 def initialize(source_table, relationship, target_table) # parent initialization super("") # additiional initialization table_name = "#{source_table}_#{relationship}_#{target_table}" @name = RDBMS.transform_name(table_name) @source_table = RDBMS.transform_name(source_table) @target_table = RDBMS.transform_name(target_table) end |
Instance Method Details
#columns ⇒ Object
Additionally return the source and target column ids plus all defined columns
19 20 21 |
# File 'lib/graph2relational/rdbms-join-table.rb', line 19 def columns [source_column, target_column] + super end |
#source_column ⇒ Object
23 24 25 |
# File 'lib/graph2relational/rdbms-join-table.rb', line 23 def source_column Column.new(source_table + "_id").foreign_key(source_table) end |
#source_table ⇒ Object
ACESSORS
38 39 40 |
# File 'lib/graph2relational/rdbms-join-table.rb', line 38 def source_table @source_table end |
#target_column ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/graph2relational/rdbms-join-table.rb', line 27 def target_column if source_table != target_table Column.new(target_table + "_id").foreign_key(target_table) else Column.new(target_table + "_id_2").foreign_key(target_table) end end |
#target_table ⇒ Object
42 43 44 |
# File 'lib/graph2relational/rdbms-join-table.rb', line 42 def target_table @target_table end |