Class: EvilEvents::Core::Events::Serializers::JSON::Unpacker Private

Inherits:
Base::DataTransformer show all
Defined in:
lib/evil_events/core/events/serializers/json/unpacker.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

Instance Attribute Summary

Attributes inherited from Base::DataTransformer

#engine

Instance Method Summary collapse

Methods inherited from Base::DataTransformer

#build_serialization_state, #initialize, #restore_event_instance

Constructor Details

This class inherits a constructor from EvilEvents::Core::Events::Serializers::Base::DataTransformer

Instance Method Details

#call(serialized_event) ⇒ EvilEvents::Core::Events::AbstractEvent

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • serialized_event (String)

Returns:

Raises:

See Also:

Since:

  • 0.4.0



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/evil_events/core/events/serializers/json/unpacker.rb', line 16

def call(serialized_event)
  raise EvilEvents::JSONDeserializationError unless serialized_event.is_a?(String)

  begin
    serialization_state = engine.load(serialized_event)
  rescue EvilEvents::SerializationEngineError
    raise EvilEvents::JSONDeserializationError
  end

  raise EvilEvents::JSONDeserializationError unless serialization_state.valid?

  restore_event_instance(serialization_state)
end