Class: EvilEvents::Core::System::EventBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evil_events/core/system/event_builder.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.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventBuilder

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.

Returns a new instance of EventBuilder.

Since:

  • 0.4.0



15
16
17
18
19
# File 'lib/evil_events/core/system/event_builder.rb', line 15

def initialize
  @serializers_container = EvilEvents::Core::Events::Serializers.new

  @serializers_container.register_core_serializers!
end

Instance Attribute Details

#serializers_containerEvilEvents::Core::Events::Serializers (readonly)

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.

Returns:

Since:

  • 0.4.0



11
12
13
# File 'lib/evil_events/core/system/event_builder.rb', line 11

def serializers_container
  @serializers_container
end

Instance Method Details

#define_abstract_event_class(event_type) ⇒ Class{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:

  • event_type (String)

Returns:

Since:

  • 0.1.0



34
35
36
# File 'lib/evil_events/core/system/event_builder.rb', line 34

def define_abstract_event_class(event_type)
  EvilEvents::Core::Events::EventFactory.create_abstract_class(event_type)
end

#define_event_class(event_type, &event_class_definitions) ⇒ Class{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:

  • event_type (String)
  • event_class_definitions (Proc)

Returns:

Since:

  • 0.1.0



26
27
28
# File 'lib/evil_events/core/system/event_builder.rb', line 26

def define_event_class(event_type, &event_class_definitions)
  EvilEvents::Core::Events::EventFactory.create_class(event_type, &event_class_definitions)
end

#deserialize_from_hash(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 (Hash)

Returns:

Since:

  • 0.1.0



86
87
88
# File 'lib/evil_events/core/system/event_builder.rb', line 86

def deserialize_from_hash(serialized_event)
  serializers_container.resolve(:hash).deserialize(serialized_event)
end

#deserialize_from_json(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:

Since:

  • 0.1.0



78
79
80
# File 'lib/evil_events/core/system/event_builder.rb', line 78

def deserialize_from_json(serialized_event)
  serializers_container.resolve(:json).deserialize(serialized_event)
end

#deserialize_from_msgpack(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:

Since:

  • 0.4.0



102
103
104
# File 'lib/evil_events/core/system/event_builder.rb', line 102

def deserialize_from_msgpack(serialized_event)
  serializers_container.resolve(:msgpack).deserialize(serialized_event)
end

#deserialize_from_xml(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:

Since:

  • 0.4.0



94
95
96
# File 'lib/evil_events/core/system/event_builder.rb', line 94

def deserialize_from_xml(serialized_event)
  serializers_container.resolve(:xml).deserialize(serialized_event)
end

#serialize_to_hash(event) ⇒ ::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.

Parameters:

Returns:

  • (::Hash)

Since:

  • 0.4.0



43
44
45
# File 'lib/evil_events/core/system/event_builder.rb', line 43

def serialize_to_hash(event)
  serializers_container.resolve(:hash).serialize(event)
end

#serialize_to_json(event) ⇒ ::String

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:

Returns:

  • (::String)

Since:

  • 0.4.0



52
53
54
# File 'lib/evil_events/core/system/event_builder.rb', line 52

def serialize_to_json(event)
  serializers_container.resolve(:json).serialize(event)
end

#serialize_to_msgpack(event) ⇒ ::String

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:

Returns:

  • (::String)

Since:

  • 0.4.0



70
71
72
# File 'lib/evil_events/core/system/event_builder.rb', line 70

def serialize_to_msgpack(event)
  serializers_container.resolve(:msgpack).serialize(event)
end

#serialize_to_xml(event) ⇒ ::String

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:

Returns:

  • (::String)

Since:

  • 0.4.0



61
62
63
# File 'lib/evil_events/core/system/event_builder.rb', line 61

def serialize_to_xml(event)
  serializers_container.resolve(:xml).serialize(event)
end