class RareMap::Column

RareMap::Column defines a column of a database table. @author Wei-Ming Wu @!attribute [r] name

@return [String] the name of this Column

@!attribute [r] type

@return [String] the type of this Column

@!attribute unique

@return [true, false] the uniqueness of this Column

@!attribute ref_table

@return [String] the reference table of this Column

Attributes

name[R]
ref_table[RW]
type[R]
unique[RW]

Public Class Methods

new(name, type, opts = {}) click to toggle source

Creates a Column.

@param name [String] the name of column @param type [String] the type of column @return [Column] a Column object

# File lib/rare_map/column.rb, line 22
def initialize(name, type, opts = {})
  @name = name
  @type = type
  @unique = opts[:unique] == true
end

Public Instance Methods

foreign_key?() click to toggle source

Checks if this Column is a foreign key.

@return [true, false] true if it’s a foreign key, false otherwise

# File lib/rare_map/column.rb, line 38
def foreign_key?
  @ref_table ? true : false
end
unique?() click to toggle source

Checks if this Column is unique.

@return [true, false] true if it’s unique, false otherwise

# File lib/rare_map/column.rb, line 31
def unique?
  @unique
end