class Egis::TableSchema

Provides DSL for defining table schemas.

@example Table schema definition

schema = Egis::TableSchema.define do
  column :id, :int
  column :message, :string

  partition :country, :string
  partition :type, :int
end

@!attribute [r] columns

@return [Egis::TableSchema::Column]

@!attribute [r] partitions

@return [Egis::TableSchema::Column]

Constants

Column

Attributes

columns[R]
partitions[R]

Public Class Methods

define(&block) click to toggle source

@return [Egis::TableSchema]

# File lib/egis/table_schema.rb, line 25
def self.define(&block)
  new(&block)
end
new(&block) click to toggle source
# File lib/egis/table_schema.rb, line 29
def initialize(&block)
  @columns = []
  @partitions = []
  instance_eval(&block)
end

Private Instance Methods

column(name, type) click to toggle source
# File lib/egis/table_schema.rb, line 39
def column(name, type)
  @columns << Column.new(name, type)
end
partition(name, type) click to toggle source
# File lib/egis/table_schema.rb, line 43
def partition(name, type)
  @partitions << Column.new(name, type)
end