gitlab-org--gitlab-foss/app/models/concerns/ignorable_column.rb
micael.bergeron d934d6504a updated the ignore_column concern to support multiple columns
This method is an ActiveRecord extension and it should behave
like one. I expected this to work.
2017-11-06 10:20:20 -05:00

28 lines
560 B
Ruby

# Module that can be included into a model to make it easier to ignore database
# columns.
#
# Example:
#
# class User < ActiveRecord::Base
# include IgnorableColumn
#
# ignore_column :updated_at
# end
#
module IgnorableColumn
extend ActiveSupport::Concern
module ClassMethods
def columns
super.reject { |column| ignored_columns.include?(column.name) }
end
def ignored_columns
@ignored_columns ||= Set.new
end
def ignore_column(*names)
ignored_columns.merge(names.map(&:to_s))
end
end
end