Module: Formatters::IndexFormatter

Includes:
Helpers::Constants
Included in:
DbmlTablesFormatter
Defined in:
lib/schema_to_dbml/formatters/index_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

Instance Method Summary collapse

Instance Method Details

#format_index(columns, index_name, unique) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/schema_to_dbml/formatters/index_formatter.rb', line 9

def format_index(columns, index_name, unique)
  formatted_columns = format_index_columns(columns)
  formatted_settings = format_index_settings(unique)
  formatted_name = "name: '#{index_name}'"
  formatted_values = [formatted_settings, formatted_name].compact.join(', ')

  "#{TAB * 2}(#{formatted_columns}) [#{formatted_values}]"
end