Class: DbmlTablesFormatter

Inherits:
Object
  • Object
show all
Includes:
Formatters::FieldsFormatter, Formatters::IndexFormatter, Helpers::Constants
Defined in:
lib/schema_to_dbml/dbml_tables_formatter.rb

Constant Summary

Constants included from Helpers::Constants

Helpers::Constants::COLUMNS_REGEXP, Helpers::Constants::INDEXES_REGEXP, Helpers::Constants::RELATIONS_REGEXP, Helpers::Constants::TAB, Helpers::Constants::TABLES_REGEXP

Constants included from Formatters::FieldsFormatter

Formatters::FieldsFormatter::COMMENT_MAPPER, Formatters::FieldsFormatter::TYPE_MAPPER

Constants included from DefaultFieldFormatterHelper

DefaultFieldFormatterHelper::DEFAULT_ARRAY_REGEX, DefaultFieldFormatterHelper::DEFAULT_BOOLEAN_REGEX, DefaultFieldFormatterHelper::DEFAULT_HASH_REGEX, DefaultFieldFormatterHelper::DEFAULT_LAMBDA_REGEX, DefaultFieldFormatterHelper::DEFAULT_NUMBER_REGEX, DefaultFieldFormatterHelper::DEFAULT_PATTERNS, DefaultFieldFormatterHelper::DEFAULT_STRING_REGEX

Instance Method Summary collapse

Methods included from Formatters::IndexFormatter

#format_index

Methods included from Formatters::FieldsFormatter

#format_comment, #format_default, #format_null, #format_type

Constructor Details

#initialize(configuration: SchemaToDbml.configuration) ⇒ DbmlTablesFormatter

Returns a new instance of DbmlTablesFormatter.



12
13
14
# File 'lib/schema_to_dbml/dbml_tables_formatter.rb', line 12

def initialize(configuration: SchemaToDbml.configuration)
  @configuration = configuration
end

Instance Method Details

#format(table_name:, table_comment:, table_attributes:) ⇒ Object



16
17
18
19
20
21
# File 'lib/schema_to_dbml/dbml_tables_formatter.rb', line 16

def format(table_name:, table_comment:, table_attributes:)
  columns = build_columns(table_name, table_attributes)
  indexes = build_indexes(table_attributes)

  format_dbml(table_name, columns, indexes, table_comment)
end