mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
22 lines
505 B
Ruby
22 lines
505 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'active_support/concern'
|
|
|
|
module LogDestroyPerformer
|
|
extend ActiveSupport::Concern
|
|
included do
|
|
attr_accessor :destroyed_by
|
|
|
|
after_destroy :log_who_destroyed
|
|
|
|
def log_who_destroyed
|
|
message = if destroyed_by.nil?
|
|
"#{self.class} #{id} deleted"
|
|
else
|
|
"#{self.class} #{id} deleted by #{destroyed_by.id} <#{destroyed_by.email}>"
|
|
end
|
|
Rails.logger.info message
|
|
end
|
|
end
|
|
end
|