class HecksAdapters::SQLDatabase::Table

Represents a SQL Table

Attributes

columns[RW]

Public Class Methods

factory(domain_objects) click to toggle source
# File lib/table.rb, line 7
def self.factory(domain_objects)
  r = domain_objects.map do |domain_object|
    new(
      name: domain_object.name,
      columns: domain_object.attributes.map do |attribute|
        Column.factory(attribute)
      end
    )
  end
end
new(name:, columns:) click to toggle source
# File lib/table.rb, line 18
def initialize(name:, columns:)
  @name = name
  @columns = columns
end

Public Instance Methods

foreign_key_columns() click to toggle source
# File lib/table.rb, line 31
def foreign_key_columns
  columns.select(&:reference?)
end
join_table_columns() click to toggle source
# File lib/table.rb, line 27
def join_table_columns
  columns.select(&:list?)
end
name() click to toggle source
# File lib/table.rb, line 35
def name
  @name.pluralize.underscore
end
to_foreign_key() click to toggle source
# File lib/table.rb, line 23
def to_foreign_key
  (name.singularize + '_id').to_sym
end