Class: Exwiw::DbSchemaGenerator::TidyResult

Inherits:
SchemaGenerator::TidyResult show all
Defined in:
lib/exwiw/db_schema_generator.rb

Overview

SchemaGenerator::TidyResult plus the belongs_tos this generator can also remove. Subclassed rather than extended in place so the ActiveRecord generator's result — and the rake task reporting it — keeps exactly the contract it has today.

Instance Attribute Summary collapse

Attributes inherited from SchemaGenerator::TidyResult

#removed_columns, #removed_tables

Instance Method Summary collapse

Methods inherited from SchemaGenerator::TidyResult

#add_removed_column, #add_removed_table

Constructor Details

#initializeTidyResult

Returns a new instance of TidyResult.



26
27
28
29
# File 'lib/exwiw/db_schema_generator.rb', line 26

def initialize
  super
  @removed_belongs_tos = {}
end

Instance Attribute Details

#removed_belongs_tosObject (readonly)

Returns the value of attribute removed_belongs_tos.



24
25
26
# File 'lib/exwiw/db_schema_generator.rb', line 24

def removed_belongs_tos
  @removed_belongs_tos
end

Instance Method Details

#add_removed_belongs_to(table_name, target_table_name) ⇒ Object



31
32
33
# File 'lib/exwiw/db_schema_generator.rb', line 31

def add_removed_belongs_to(table_name, target_table_name)
  (@removed_belongs_tos[table_name] ||= []) << target_table_name
end

#empty?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/exwiw/db_schema_generator.rb', line 35

def empty?
  super && @removed_belongs_tos.empty?
end