Class: TorqueBox::Messaging::JSONMessage
- Defined in:
- lib/torquebox/messaging/json_message.rb
Constant Summary collapse
- ENCODING =
:json
- JMS_TYPE =
:text
Constants inherited from Message
Message::DEFAULT_DECODE_ENCODING, Message::DEFAULT_ENCODE_ENCODING, Message::ENCODING_PROPERTY
Instance Attribute Summary
Attributes inherited from Message
Instance Method Summary collapse
Methods inherited from Message
__new__, class_for_encoding, encoding_map, extract_encoding_from_message, inherited, #initialize, #initialize_from_message, #method_missing, new, #populate_message_headers, #populate_message_properties, register_encoding, #respond_to?, #set_encoding
Constructor Details
This class inherits a constructor from TorqueBox::Messaging::Message
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TorqueBox::Messaging::Message
Instance Method Details
#decode ⇒ Object
41 42 43 44 |
# File 'lib/torquebox/messaging/json_message.rb', line 41 def decode require_json JSON.parse( @jms_message.text, :symbolize_names => true ) unless @jms_message.text.nil? end |
#encode(message) ⇒ Object
36 37 38 39 |
# File 'lib/torquebox/messaging/json_message.rb', line 36 def encode() require_json @jms_message.text = JSON.fast_generate( ) unless .nil? end |
#require_json ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/torquebox/messaging/json_message.rb', line 24 def require_json # We can't ship our own json, as it may collide with the gem # requirement for the app. if !defined?( JSON ) begin require 'json' rescue LoadError => ex raise RuntimeError.new( "Unable to load the json gem. Verify that is installed and in your Gemfile (if using Bundler)" ) end end end |