Class: Chicago::Schema::Table Abstract
- Inherits:
-
Object
- Object
- Chicago::Schema::Table
- Includes:
- NamedElement
- Defined in:
- lib/chicago/schema/table.rb
Overview
Base class for Dimensions & Facts.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Documentation or description for the table.
-
#natural_key ⇒ Object
readonly
The uniqueness constraint on the table.
-
#table_name ⇒ Object
readonly
Returns the database table name for this dimension or fact.
Attributes included from NamedElement
Instance Method Summary collapse
-
#[](name) ⇒ Object
Returns the column named ‘name’.
-
#initialize(name, opts = {}) ⇒ Table
constructor
private
A new instance of Table.
-
#qualify(col) ⇒ Object
Returns the name of the column, qualified by this schema table.
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
#description ⇒ Object (readonly)
Documentation or description for the table.
20 21 22 |
# File 'lib/chicago/schema/table.rb', line 20 def description @description end |
#natural_key ⇒ Object (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_name ⇒ Object (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 |