Class: TableStructure::Schema::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/table_structure/schema/table.rb,
lib/table_structure/schema/table/key_decorator.rb

Defined Under Namespace

Classes: KeyDecorator

Instance Method Summary collapse

Constructor Details

#initialize(columns, context, options) ⇒ Table



6
7
8
9
10
11
12
13
14
# File 'lib/table_structure/schema/table.rb', line 6

def initialize(
  columns,
  context,
  options
)
  @columns = columns
  @context = context
  @options = options
end

Instance Method Details

#header(context: nil) ⇒ Object



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

def header(context: nil)
  values(:names, context)
end

#row(context: nil) ⇒ Object



20
21
22
# File 'lib/table_structure/schema/table.rb', line 20

def row(context: nil)
  values(:values, context)
end

#rows(items) ⇒ Object



24
25
26
27
28
# File 'lib/table_structure/schema/table.rb', line 24

def rows(items)
  Enumerator.new do |y|
    items.each { |item| y << row(context: item) }
  end
end