Module: Bolt::Util::Format

Defined in:
lib/bolt/util/format.rb

Class Method Summary collapse

Class Method Details

.stringify(message) ⇒ String

Stringifies an object, formatted as valid JSON.

Parameters:

  • message (Object)

    The object to stringify.

Returns:

  • (String)

    The JSON string.


12
13
14
15
16
17
18
19
# File 'lib/bolt/util/format.rb', line 12

def stringify(message)
  formatted = format_message(message)
  if formatted.is_a?(Hash) || formatted.is_a?(Array)
    ::JSON.pretty_generate(formatted)
  else
    formatted
  end
end