Class: TableStructure::Schema::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/table_structure/schema/definition.rb,
lib/table_structure/schema/definition/error.rb,
lib/table_structure/schema/definition/compiler.rb,
lib/table_structure/schema/definition/validator.rb

Defined Under Namespace

Classes: Compiler, Error, Validator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, column_definitions, context_builders, column_converters, result_builders, context, options) ⇒ Definition

Returns a new instance of Definition.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/table_structure/schema/definition.rb', line 8

def initialize(
  name,
  column_definitions,
  context_builders,
  column_converters,
  result_builders,
  context,
  options
)
  @name = name
  @context_builders = ContextBuilders.new(context_builders)
  @column_converters = ColumnConverters.new(column_converters)
  @result_builders = ResultBuilders.new(result_builders)
  @context = @context_builders.build_for_table(context)
  @options = options

  @columns = create_columns(@name, column_definitions, @context, @options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/table_structure/schema/definition.rb', line 6

def options
  @options
end

Instance Method Details

#create_table(**options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/table_structure/schema/definition.rb', line 27

def create_table(**options)
  options = @options.merge(options)

  table = Table.new(
    @columns,
    @context,
    options
  )

  @context_builders.extend_methods_for(table)
  @column_converters.extend_methods_for(table)
  @result_builders.extend_methods_for(table)

  table
end