Class: EvilEvents::Core::Events::Serializers::Hash::Engines::Native Private
- Inherits:
-
Base::AbstractEngine
- Object
- Base::AbstractEngine
- EvilEvents::Core::Events::Serializers::Hash::Engines::Native
- Defined in:
- lib/evil_events/core/events/serializers/hash/engines/native.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.
Instance Method Summary collapse
- #dump(serialization_state) ⇒ ::Hash private
- #load(hash) ⇒ EventSerializationState private
- #symbolized_hash(hash) ⇒ ::Hash private private
Methods inherited from Base::AbstractEngine
#initialize, #restore_serialization_state
Constructor Details
This class inherits a constructor from EvilEvents::Core::Events::Serializers::Base::AbstractEngine
Instance Method Details
#dump(serialization_state) ⇒ ::Hash
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.
12 13 14 15 16 17 18 19 |
# File 'lib/evil_events/core/events/serializers/hash/engines/native.rb', line 12 def dump(serialization_state) { id: serialization_state.id, type: serialization_state.type, payload: serialization_state.payload, metadata: serialization_state. } end |
#load(hash) ⇒ EventSerializationState
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/evil_events/core/events/serializers/hash/engines/native.rb', line 27 def load(hash) begin event_id = hash[:id] || hash['id'] event_type = hash[:type] || hash['type'] event_payload = hash[:payload] || hash['payload'] = hash[:metadata] || hash['metadata'] rescue NoMethodError, TypeError, ArgumentError raise EvilEvents::SerializationEngineError end restore_serialization_state( id: event_id, type: event_type, payload: (symbolized_hash(event_payload) if event_payload), metadata: (symbolized_hash() if ) ) end |
#symbolized_hash(hash) ⇒ ::Hash (private)
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.
51 52 53 54 55 |
# File 'lib/evil_events/core/events/serializers/hash/engines/native.rb', line 51 def symbolized_hash(hash) hash.each_pair.each_with_object({}) do |(key, value), result_hash| result_hash[key.to_sym] = value end end |