Class: Gruf::Serializers::Errors::Json

Inherits:
Base
  • Object
show all
Defined in:
lib/gruf/serializers/errors/json.rb

Overview

Serializes the error via JSON for transport

Instance Attribute Summary

Attributes inherited from Base

#error

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gruf::Serializers::Errors::Base

Instance Method Details

#deserializeHash

Returns A hash deserialized from the inputted JSON.

Returns:

  • (Hash)

    A hash deserialized from the inputted JSON



35
36
37
# File 'lib/gruf/serializers/errors/json.rb', line 35

def deserialize
  JSON.parse(@error)
end

#serializeString

Returns The serialized JSON string.

Returns:

  • (String)

    The serialized JSON string



28
29
30
# File 'lib/gruf/serializers/errors/json.rb', line 28

def serialize
  @error.to_h.to_json
end