Class: Formatters::DictFormatter
- Inherits:
-
BasicFormatter
- Object
- BasicFormatter
- Formatters::DictFormatter
- Defined in:
- lib/formatters/dict_formatter.rb
Overview
Formatter of message into dictionary format
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasicFormatter
Instance Method Summary collapse
-
#get_as_dictionary ⇒ Object
Format message as dictionary ==== Returns message formatted as dictionary.
-
#initialize(message, msg_content_hashed = false) ⇒ DictFormatter
constructor
- Initialization of dictionary formatter ==== Dictionary formatter arguments message
-
message to format.
-
#print ⇒ Object
Prints message formatted as dictionary to stdout.
Methods inherited from BasicFormatter
Constructor Details
#initialize(message, msg_content_hashed = false) ⇒ DictFormatter
Initialization of dictionary formatter
Dictionary formatter arguments
- message
-
message to format
27 28 29 |
# File 'lib/formatters/dict_formatter.rb', line 27 def initialize(, msg_content_hashed=false) super(, msg_content_hashed) end |
Instance Method Details
#get_as_dictionary ⇒ Object
Format message as dictionary
Returns
message formatted as dictionary
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 ⇒ Object
Prints message formatted as dictionary to stdout
57 58 59 60 |
# File 'lib/formatters/dict_formatter.rb', line 57 def print() # Print formatted message to stdout puts get_as_dictionary() end |