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



63
64
65
66
67
# File 'lib/table_renamable/model.rb', line 63

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



74
75
76
77
# File 'lib/table_renamable/model.rb', line 74

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:



86
87
88
89
90
# File 'lib/table_renamable/model.rb', line 86

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