class Scheman::Schema::Table

Public Class Methods

new(table) click to toggle source
# File lib/scheman/schema.rb, line 36
def initialize(table)
  @table = table
end

Public Instance Methods

fields() click to toggle source

@return [Array<Field>]

# File lib/scheman/schema.rb, line 46
def fields
  @table[:fields].map do |field|
    Field.new(field[:field])
  end
end
fields_indexed_by_name() click to toggle source

@return [Hash{String => Field}]

# File lib/scheman/schema.rb, line 53
def fields_indexed_by_name
  @fields_indexed_by_name ||= fields.index_by(&:name)
end
indices() click to toggle source

@return [Array<Hash>]

# File lib/scheman/schema.rb, line 58
def indices
  @indices ||= indices_from_definitions + indices_from_fields
end
name() click to toggle source

@return [String]

# File lib/scheman/schema.rb, line 41
def name
  @table[:name]
end

Private Instance Methods

indices_from_definitions() click to toggle source
# File lib/scheman/schema.rb, line 64
def indices_from_definitions
  @table[:indices].map do |hash|
    hash[:index]
  end
end
indices_from_fields() click to toggle source

@return [Array<Hash>]

# File lib/scheman/schema.rb, line 71
def indices_from_fields
  fields.map(&:index).compact
end