Class: Spinoza::Table

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#columnsObject (readonly)

Returns the value of attribute columns.



6
7
8
# File 'lib/spinoza/system/table.rb', line 6

def columns
  @columns
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/spinoza/system/table.rb', line 5

def name
  @name
end