Class: StaffMessageFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/staff_message_format.rb

Overview

This is used for formatting Suspension/Silencing messages. It can be extended by plugins to provide custom message formats.

Instance Method Summary collapse

Constructor Details

#initialize(type, reason, message = nil) ⇒ StaffMessageFormat

Returns a new instance of StaffMessageFormat.



6
7
8
9
10
11
12
# File 'lib/staff_message_format.rb', line 6

def initialize(type, reason, message = nil)
  @type = type
  @reason = reason
  @message = message

  after_initialize
end

Instance Method Details

#after_initializeObject

Plugins can overwrite this to munge values before formatting



15
16
# File 'lib/staff_message_format.rb', line 15

def after_initialize
end

#formatObject

Overwrite this to change formatting



19
20
21
22
23
24
# File 'lib/staff_message_format.rb', line 19

def format
  result = +""
  result << @reason if @reason.present?
  result << "\n\n#{@message}" if @message.present?
  result
end