Class: Spinoza::Table
- Inherits:
-
Object
- Object
- Spinoza::Table
- Defined in:
- lib/spinoza/system/table.rb
Overview
Defines the schema for one table in all replicas. No state.
Defined Under Namespace
Classes: Column
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, **specs) ⇒ Table
constructor
Usage:.
Constructor Details
#initialize(name, **specs) ⇒ Table
Usage:
create_table :Widgets, id: "integer", weight: "float", name: "string"
The first column is the primary key for the table.
24 25 26 27 28 29 30 |
# File 'lib/spinoza/system/table.rb', line 24 def initialize name, **specs @name = name @columns = [] specs.each_with_index do |(col_name, col_type), i| @columns << Column.new(col_name, col_type, (i==0)) end end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/spinoza/system/table.rb', line 6 def columns @columns end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/spinoza/system/table.rb', line 5 def name @name end |