class Formatters::DictFormatter
Formatter of message into dictionary format
Public Class Methods
new(message, msg_content_hashed=false)
click to toggle source
Initialization of dictionary formatter
Dictionary formatter arguments¶ ↑
- message
-
message to format
Calls superclass method
Formatters::BasicFormatter::new
# File lib/formatters/dict_formatter.rb, line 27 def initialize(message, msg_content_hashed=false) super(message, msg_content_hashed) end
Public Instance Methods
get_as_dictionary()
click to toggle source
Format message as dictionary
Returns¶ ↑
message formatted as dictionary
# File lib/formatters/dict_formatter.rb, line 34 def get_as_dictionary() dict_to_return = "" \ + "'redelivered': #{format_value( @message.delivery_count == 0 ? false : true )}, "\ + "'reply-to': #{format_value(@message.reply_to)}, "\ + "'subject': #{format_value(@message.subject)}, "\ + "'content-type': #{format_value(@message.content_type)}, "\ + "'id': #{format_value(@message.id)}, "\ + "'group-id': #{format_value(@message.group_id)}, "\ + "'user-id': #{format_value(@message.user_id)}, "\ + "'correlation-id': #{format_value(@message.correlation_id)}, "\ + "'priority': #{format_value(@message.priority)}, "\ + "'durable': #{format_value(@message.durable)}, "\ + "'ttl': #{format_value(@message.ttl)}, "\ + "'properties': #{format_value(@message.properties)}, "\ + "'content': #{ format_value(@msg_content_hashed ? StringUtils.sha1_hash(@message.body) : @message.body) }" return self.class.escape_chars("{#{dict_to_return}}") end
print()
click to toggle source
Prints message formatted as dictionary to stdout
# File lib/formatters/dict_formatter.rb, line 57 def print() # Print formatted message to stdout puts get_as_dictionary() end