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/dsl/option.rb,
lib/table_structure/schema/column/attrs.rb,
lib/table_structure/schema/class_methods.rb,
lib/table_structure/schema/column/schema.rb,
lib/table_structure/schema/column/factory.rb,
lib/table_structure/schema/result_builders.rb,
lib/table_structure/schema/context_builders.rb,
lib/table_structure/schema/column_converters.rb,
lib/table_structure/schema/dsl/result_builder.rb,
lib/table_structure/schema/dsl/context_builder.rb,
lib/table_structure/schema/table/key_decorator.rb,
lib/table_structure/schema/dsl/column_converter.rb,
lib/table_structure/schema/dsl/column_definition.rb,
lib/table_structure/schema/column/definition/error.rb,
lib/table_structure/schema/column/definition/compiler.rb,
lib/table_structure/schema/column/definition/validator.rb
Defined Under Namespace
Modules: ClassMethods, Column, DSL, Utils Classes: ColumnConverter, ColumnConverters, ContextBuilder, ContextBuilders, Definition, ResultBuilder, ResultBuilders, Table
Class Method Summary collapse
Instance Method Summary collapse
-
#create_table(**options) ⇒ Object
TODO: Specify options using keyword arguments.
- #initialize(name: self.class.name, context: nil, name_prefix: nil, name_suffix: nil, key_prefix: nil, key_suffix: nil, nil_definitions_ignored: false, **deprecated_options) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 9 10 11 12 |
# 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) klass.extend(ClassMethods) end |
Instance Method Details
#create_table(**options) ⇒ Object
TODO: Specify options using keyword arguments.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/table_structure/schema.rb', line 70 def create_table(**) = @_definition_..merge() table = Table.new( @_definition_.columns, @_definition_.context, ) @_definition_.context_builders.extend_methods_for(table) = { name_prefix: [:name_prefix], name_suffix: [:name_suffix] } @_definition_.column_converters.extend_methods_for(table, **) = { result_type: [:result_type] } @_definition_.result_builders.extend_methods_for(table, **) if block_given? yield table else table end end |
#initialize(name: self.class.name, context: nil, name_prefix: nil, name_suffix: nil, key_prefix: nil, key_suffix: nil, nil_definitions_ignored: false, **deprecated_options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/table_structure/schema.rb', line 25 def initialize( name: self.class.name, context: nil, name_prefix: nil, name_suffix: nil, key_prefix: nil, key_suffix: nil, nil_definitions_ignored: false, ** ) unless .empty? caller_location = caller_locations(1, 1) .keys.each do |k| warn "[TableStructure] Specify :#{k} option on the writer or the iterator. #{caller_location}" end end = { name_prefix: name_prefix, name_suffix: name_suffix, key_prefix: key_prefix, key_suffix: key_suffix, nil_definitions_ignored: nil_definitions_ignored }.merge!(self.class.).merge!() context_builders = ContextBuilders.new({}.merge!(self.class.context_builders)) column_converters = ColumnConverters.new({}.merge!(self.class.column_converters)) result_builders = ResultBuilders.new({}.merge!(self.class.result_builders)) context = context_builders.build_for_table(context) columns = Column::Factory.create(name, self.class.column_definitions, context, ) @_definition_ = Definition.new( name, columns, context_builders, column_converters, result_builders, context, ) end |