discourse/lib/staff_message_format.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

26 lines
601 B
Ruby

# frozen_string_literal: true
# This is used for formatting Suspension/Silencing messages.
# It can be extended by plugins to provide custom message formats.
class StaffMessageFormat
def initialize(type, reason, message = nil)
@type = type
@reason = reason
@message = message
after_initialize
end
# Plugins can overwrite this to munge values before formatting
def after_initialize
end
# Overwrite this to change formatting
def format
result = +""
result << @reason if @reason.present?
result << "\n\n#{@message}" if @message.present?
result
end
end