Class: Ramen::Metadata::ForeignKeyColumn
- Inherits:
-
RowDataGateway
- Object
- RowDataGateway
- Ramen::Metadata::ForeignKeyColumn
- Defined in:
- lib/ramen/metadata/foreign_key_column.rb
Overview
ForeignKeyColumn contains meta-data about columns within a ForeignKey. The attributes are database engine specific.
Only column_name and column_id are required by Ramen. See RowDataGateway for more information.
Reference Attributes:
- column
-
the foreign key column in the table.
- referenced_column
-
the column in the foreign table.
See Database for a description of how ForeignKeyColumn fits in the Ramen collection hierarchy.
Links: readme.txt; source
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#referenced_column ⇒ Object
readonly
Returns the value of attribute referenced_column.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Comparison, returns -1,0,+1, compares column_name.
-
#add_to(database) ⇒ Object
add_to( database ).
-
#initialize(record, database) ⇒ ForeignKeyColumn
constructor
:section: Internal Methods The following methods are for Ramen’s internal use.
Methods inherited from RowDataGateway
Constructor Details
#initialize(record, database) ⇒ ForeignKeyColumn
:section: Internal Methods The following methods are for Ramen’s internal use. They are not intended for clients of Ramen to use.
36 37 38 39 40 |
# File 'lib/ramen/metadata/foreign_key_column.rb', line 36 def initialize( record, database ) super( record, database ) @column = database.schema[ self.table_schema ].table[ self.table_name ].column[ self.column_name ] @referenced_column = database.schema[ self.referenced_table_schema ].table[ self.referenced_table_name ].column[ self.referenced_column_name ] end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
22 23 24 |
# File 'lib/ramen/metadata/foreign_key_column.rb', line 22 def column @column end |
#referenced_column ⇒ Object (readonly)
Returns the value of attribute referenced_column.
22 23 24 |
# File 'lib/ramen/metadata/foreign_key_column.rb', line 22 def referenced_column @referenced_column end |
Instance Method Details
#<=>(other) ⇒ Object
Comparison, returns -1,0,+1, compares column_name
28 29 30 |
# File 'lib/ramen/metadata/foreign_key_column.rb', line 28 def <=> other Ramen::RowDataGateway.compare( column_name, other ) end |
#add_to(database) ⇒ Object
add_to( database )
Add self to the given database. (Choosing Message; Double Dispatch pattern) (Kent Beck. Smalltalk Best Practices Patterns. Perntice Hall PTR, Upper Saddle River, NJ 1997)
46 47 48 49 |
# File 'lib/ramen/metadata/foreign_key_column.rb', line 46 def add_to( database ) database.schema[ self.table_schema ].table[ self.table_name ]. fk[ self.foreign_key_name ].add_column( self ) end |