Class: Ramen::Metadata::PrimaryKeyColumn

Inherits:
RowDataGateway show all
Defined in:
lib/ramen/metadata/primary_key_column.rb

Overview

PrimaryKeyColumn contains meta-data about columns within a PrimaryKey. 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 primary key column in the table.

See Database for a description of how PrimaryKeyColumn fits in the Ramen collection hierarchy.

Links: readme.txt; source

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RowDataGateway

add_attributes, compare

Constructor Details

#initialize(record, database) ⇒ PrimaryKeyColumn

:section: Internal Methods The following methods are for Ramen’s internal use. They are not intended for clients of Ramen to use.



35
36
37
38
# File 'lib/ramen/metadata/primary_key_column.rb', line 35

def initialize( record, database )
  super( record, database )
  @column = database.schema[ self.table_schema ].table[ self.table_name ].column[ self.column_name ]
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



21
22
23
# File 'lib/ramen/metadata/primary_key_column.rb', line 21

def column
  @column
end

Instance Method Details

#<=>(other) ⇒ Object

Comparison, returns -1,0,+1, compares column_name



27
28
29
# File 'lib/ramen/metadata/primary_key_column.rb', line 27

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)



44
45
46
47
# File 'lib/ramen/metadata/primary_key_column.rb', line 44

def add_to( database )
  database.schema[ self.table_schema ].table[ self.table_name ].
    pk.add_column( self )
end