Class: Pheromone::Messaging::MessageFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pheromone/messaging/message_formatter.rb

Constant Summary collapse

SUPPORTED_MESSAGE_FORMATS =
[:json].freeze

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ MessageFormatter

Returns a new instance of MessageFormatter.



7
8
9
# File 'lib/pheromone/messaging/message_formatter.rb', line 7

def initialize(message)
  @message = message
end

Instance Method Details

#formatObject



11
12
13
14
15
16
17
# File 'lib/pheromone/messaging/message_formatter.rb', line 11

def format
  if Pheromone.config.message_format == :json
    convert_to_time_format.to_json
  elsif !SUPPORTED_MESSAGE_FORMATS.include?(Pheromone.config.message_format)
    raise Pheromone::Exceptions::UnsupportedMessageFormat.new
  end
end