Class: Chicago::Schema::Table Abstract

Inherits:
Object
  • Object
show all
Includes:
NamedElement
Defined in:
lib/chicago/schema/table.rb

Overview

This class is abstract.

Base class for Dimensions & Facts.

Direct Known Subclasses

Dimension, Fact

Instance Attribute Summary collapse

Attributes included from NamedElement

#label, #name

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Table

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Table.



23
24
25
26
27
# File 'lib/chicago/schema/table.rb', line 23

def initialize(name, opts={})
  super
  @natural_key = opts[:natural_key]
  @description = opts[:description]
end

Instance Attribute Details

#descriptionObject (readonly)

Documentation or description for the table.



20
21
22
# File 'lib/chicago/schema/table.rb', line 20

def description
  @description
end

#natural_keyObject (readonly)

The uniqueness constraint on the table.



17
18
19
# File 'lib/chicago/schema/table.rb', line 17

def natural_key
  @natural_key
end

#table_nameObject (readonly)

Returns the database table name for this dimension or fact. By default, dimension_<name> or facts_<name>.



14
15
16
# File 'lib/chicago/schema/table.rb', line 14

def table_name
  @table_name
end

Instance Method Details

#[](name) ⇒ Object

Returns the column named ‘name’.



36
37
38
# File 'lib/chicago/schema/table.rb', line 36

def [](name)
  columns.detect {|c| c.name == name }
end

#qualify(col) ⇒ Object

Returns the name of the column, qualified by this schema table. This is a Sequel::SQL::QualifiedIdentifier.



31
32
33
# File 'lib/chicago/schema/table.rb', line 31

def qualify(col)
  col.name.qualify(table_name)
end