Class: TableQuery::TableSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/table-query/table-schema.rb

Overview

TableSchema defines table fields.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTableSchema

Create a new table schema.



19
20
21
# File 'lib/table-query/table-schema.rb', line 19

def initialize
  @fields = []
end

Instance Attribute Details

#fieldsArray<Field> (readonly)

table field list

Returns:



16
17
18
# File 'lib/table-query/table-schema.rb', line 16

def fields
  @fields
end

Class Method Details

.define(&b) ⇒ TableSchema

Define a new table schema.

Parameters:

  • b (Proc)

    schema definition

Returns:



10
11
12
# File 'lib/table-query/table-schema.rb', line 10

def self.define(&b)
  new.tap {|x| x.instance_eval(&b)}
end

Instance Method Details

#field(name, type) ⇒ void

This method returns an undefined value.

Add a table field.

Parameters:

  • name (Symbol)

    field name

  • type (Symbol)

    field type name



30
31
32
# File 'lib/table-query/table-schema.rb', line 30

def field(name, type)
  @fields << Field.new(name, type, @fields.size, nil, {})
end