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
5
6
7
8
9
10
11
|
# File 'lib/table_structure/schema.rb', line 5
def self.included(klass)
klass.extend(DSL::ColumnConverter)
klass.extend(DSL::ColumnDefinition)
klass.extend(DSL::ContextBuilder)
klass.extend(DSL::Option)
klass.extend(DSL::ResultBuilder)
end
|
Instance Method Details
#column_converters ⇒ Object
49
50
51
|
# File 'lib/table_structure/schema.rb', line 49
def column_converters
@table_structure_schema_table_.column_converters
end
|
35
36
37
38
39
40
|
# File 'lib/table_structure/schema.rb', line 35
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, **options) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/table_structure/schema.rb', line 19
def initialize(context: nil, **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(
column_definitions,
column_converters,
result_builders,
context,
options
)
end
|
#result_builders ⇒ Object
53
54
55
|
# File 'lib/table_structure/schema.rb', line 53
def result_builders
@table_structure_schema_table_.result_builders
end
|
#row(context: nil, result_type: nil) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/table_structure/schema.rb', line 42
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
|