Class: Ably::Models::MessageEncoders::Json
- Defined in:
- lib/ably/models/message_encoders/json.rb
Overview
JSON Encoder and Decoder Uses encoding identifier ‘json’ and encodes all objects that are not strings or byte arrays
Constant Summary collapse
- ENCODING_ID =
'json'
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#add_encoding_to_message, #current_encoding_part, #initialize, #is_empty?, #strip_current_encoding_part
Constructor Details
This class inherits a constructor from Ably::Models::MessageEncoders::Base
Instance Method Details
#decode(message, channel_options) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ably/models/message_encoders/json.rb', line 18 def decode(, ) if is_json_encoded?() [:data] = ::JSON.parse([:data]) strip_current_encoding_part end end |
#encode(message, channel_options) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/ably/models/message_encoders/json.rb', line 11 def encode(, ) if needs_json_encoding?() [:data] = ::JSON.dump([:data]) ENCODING_ID, end end |