Module: TableRenamable::Model::ClassMethods

Defined in:
lib/table_renamable/model.rb

Overview

ClassMethods to be mixed in to the model using this behavior

Instance Method Summary collapse

Instance Method Details

#columnsArray<>

Overrides columns to remove deprecated columns

Returns:

  • (Array<>)

    Filtered array of columns



61
62
63
64
65
# File 'lib/table_renamable/model.rb', line 61

def columns
  super.reject { |column|
    self.deprecated_columns.include?(column.name)
  }
end

#deprecate_columns(*column_names) ⇒ Array<String>

Mark columns as deprecated

Parameters:

  • *column_names (Array<String, Symbol>)

    Column names

Returns:

  • (Array<String>)

    List of deprecated columns



72
73
74
75
# File 'lib/table_renamable/model.rb', line 72

def deprecate_columns(*column_names)
  self.deprecated_columns =
    self.deprecated_columns + Array.wrap(column_names).collect(&:to_s)
end

#deprecate_table_name(old_name, new_name) ⇒ TableRenamable::DeprecatedTable

Mark this class as having a potentially new table name created TableRenamable::DeprecatedTable records

Parameters:

  • old_name (String, Symbol)

    The old table name

  • new_name (String, Symbol)

    The new table name

Returns:



84
85
86
87
88
# File 'lib/table_renamable/model.rb', line 84

def deprecate_table_name(old_name, new_name)
  deprecated_table = DeprecatedTable.new(self, old_name, new_name)
  TableRenamable::Model.deprecated_tables << deprecated_table
  deprecated_table
end