Class: Moleculer::Serializers::Json
- Inherits:
-
Object
- Object
- Moleculer::Serializers::Json
- Defined in:
- lib/moleculer/serializers/json.rb
Overview
Serializes data packets to and from JSON
Instance Method Summary collapse
- #deserialize(message) ⇒ Object
-
#initialize(config) ⇒ Json
constructor
A new instance of Json.
- #serialize(message) ⇒ Object
Constructor Details
#initialize(config) ⇒ Json
Returns a new instance of Json.
8 9 10 11 |
# File 'lib/moleculer/serializers/json.rb', line 8 def initialize(config) @logger = config.logger.get_child("[SERIALIZER]") @config = config end |
Instance Method Details
#deserialize(message) ⇒ Object
17 18 19 20 21 |
# File 'lib/moleculer/serializers/json.rb', line 17 def deserialize() JSON.parse() rescue StandardError => e @config.handle_error(e) end |
#serialize(message) ⇒ Object
13 14 15 |
# File 'lib/moleculer/serializers/json.rb', line 13 def serialize() .to_h.to_json end |