Class: Pheromone::Messaging::MessageFormatter
- Inherits:
-
Object
- Object
- Pheromone::Messaging::MessageFormatter
- Includes:
- Pheromone::MethodInvoker
- Defined in:
- lib/pheromone/messaging/message_formatter.rb
Constant Summary collapse
- SUPPORTED_MESSAGE_FORMATS =
[:json, :with_encoding].freeze
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(message, encoder, format) ⇒ MessageFormatter
constructor
A new instance of MessageFormatter.
Methods included from Pheromone::MethodInvoker
Constructor Details
#initialize(message, encoder, format) ⇒ MessageFormatter
Returns a new instance of MessageFormatter.
8 9 10 11 12 |
# File 'lib/pheromone/messaging/message_formatter.rb', line 8 def initialize(, encoder, format) @message = @encoder = encoder @message_format = format end |
Instance Method Details
#format ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pheromone/messaging/message_formatter.rb', line 14 def format if == :json .to_json elsif == :with_encoding call_proc_or_instance_method( @encoder, .with_indifferent_access ) elsif !SUPPORTED_MESSAGE_FORMATS.include?(Pheromone.config.) raise Pheromone::Exceptions::UnsupportedMessageFormat.new end end |