Module: TableStructure::Schema
- Defined in:
- lib/table_structure/schema.rb,
lib/table_structure/schema/table.rb,
lib/table_structure/schema/utils.rb,
lib/table_structure/schema/column.rb,
lib/table_structure/schema/definition.rb,
lib/table_structure/schema/dsl/option.rb,
lib/table_structure/schema/column/attrs.rb,
lib/table_structure/schema/column/schema.rb,
lib/table_structure/schema/definition/error.rb,
lib/table_structure/schema/dsl/result_builder.rb,
lib/table_structure/schema/dsl/context_builder.rb,
lib/table_structure/schema/definition/validator.rb,
lib/table_structure/schema/dsl/column_converter.rb,
lib/table_structure/schema/dsl/column_definition.rb
Defined Under Namespace
Modules: Column, DSL, Utils
Classes: Definition, Table
Constant Summary
collapse
- DEFAULT_OPTIONS =
{
result_type: :array, key_prefix: nil,
key_suffix: nil
}.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(klass) ⇒ Object
Instance Method Details
#column_converters ⇒ Object
50
51
52
|
# File 'lib/table_structure/schema.rb', line 50
def column_converters
@table_structure_schema_table_.column_converters
end
|
36
37
38
39
40
41
|
# File 'lib/table_structure/schema.rb', line 36
def (context: nil, result_type: nil)
result_type ||= @table_structure_schema_table_.options[:result_type]
context = self.class.context_builders[:header].call(context)
@table_structure_schema_table_.(context, result_type)
end
|
#initialize(context: nil, name: self.class.name, **options) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/table_structure/schema.rb', line 19
def initialize(context: nil, name: self.class.name, **options)
column_definitions = self.class.column_definitions
column_converters = self.class.column_converters
result_builders = self.class.result_builders
context = self.class.context_builders[:table].call(context)
options = DEFAULT_OPTIONS.merge(self.class.options).merge(options)
@table_structure_schema_table_ =
Table.new(
name,
column_definitions,
column_converters,
result_builders,
context,
options
)
end
|
#result_builders ⇒ Object
54
55
56
|
# File 'lib/table_structure/schema.rb', line 54
def result_builders
@table_structure_schema_table_.result_builders
end
|
#row(context: nil, result_type: nil) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/table_structure/schema.rb', line 43
def row(context: nil, result_type: nil)
result_type ||= @table_structure_schema_table_.options[:result_type]
context = self.class.context_builders[:row].call(context)
@table_structure_schema_table_.row_values(context, result_type)
end
|