Commit becc6637 authored by Andreas Brandl's avatar Andreas Brandl

Simplify mutex pattern

parent 9d34272d
...@@ -23,19 +23,21 @@ module IgnorableColumns ...@@ -23,19 +23,21 @@ module IgnorableColumns
self.ignored_columns += columns.flatten # rubocop:disable Cop/IgnoredColumns self.ignored_columns += columns.flatten # rubocop:disable Cop/IgnoredColumns
IGNORE_COLUMN_MUTEX.synchronize do columns.flatten.each do |column|
@ignored_columns_details ||= superclass.try(:ignored_columns_details)&.dup || {} self.ignored_columns_details[column.to_sym] = ColumnIgnore.new(Date.parse(remove_after), remove_with)
columns.flatten.each do |column|
@ignored_columns_details[column.to_sym] = ColumnIgnore.new(Date.parse(remove_after), remove_with)
end
end end
end end
alias_method :ignore_column, :ignore_columns alias_method :ignore_column, :ignore_columns
def ignored_columns_details def ignored_columns_details
@ignored_columns_details || {} unless defined?(@ignored_columns_details)
IGNORE_COLUMN_MUTEX.synchronize do
@ignored_columns_details ||= superclass.try(:ignored_columns_details)&.dup || {}
end
end
@ignored_columns_details
end end
IGNORE_COLUMN_MUTEX = Mutex.new IGNORE_COLUMN_MUTEX = Mutex.new
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment