Module: EvilEvents::Core::Events::EventFactory Private
- Defined in:
- lib/evil_events/core/events/event_factory.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- UNDEFINED_EVENT_ID =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'unknown'
- CLASS_INHERITANCE_STRATEGY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:class_inheritance
- PROC_EVAL_STRATEGY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:proc_eval
Class Method Summary collapse
- .create_abstract_class(event_type) ⇒ Class{EvilEvents::Core::Events::AbstractEvent} private
- .create_class(event_type, &event_class_definitions) {|AbstractEvent| ... } ⇒ Class{EvilEvents::Core::Events::AbstractEvent} private
- .restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {}) ⇒ EvilEvents::Core::Events::AbstractEvent private
Instance Method Summary collapse
- #create_abstract_class(event_type) ⇒ Class{EvilEvents::Core::Events::AbstractEvent} private private
- #create_class(event_type, &event_class_definitions) {|AbstractEvent| ... } ⇒ Class{EvilEvents::Core::Events::AbstractEvent} private private
- #restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {}) ⇒ EvilEvents::Core::Events::AbstractEvent private private
Class Method Details
.create_abstract_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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/evil_events/core/events/event_factory.rb', line 19 def create_abstract_class(event_type) Class.new(AbstractEvent).tap do |klass| klass.type(event_type) klass.__creation_strategy__ = CLASS_INHERITANCE_STRATEGY class << klass def inherited(child_class) child_class.type(type) child_class.__creation_strategy__ = CLASS_INHERITANCE_STRATEGY child_class.manage! rescue EvilEvents::AlreadyManagedEventClassError EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class) raise end end end end |
.create_class(event_type, &event_class_definitions) {|AbstractEvent| ... } ⇒ 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/evil_events/core/events/event_factory.rb', line 44 def create_class(event_type, &event_class_definitions) Class.new(AbstractEvent).tap do |klass| begin klass.__creation_strategy__ = PROC_EVAL_STRATEGY klass.type(event_type) klass.manage! klass.evaluate(&event_class_definitions) if block_given? rescue StandardError EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass) raise end end end |
.restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {}) ⇒ 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.
66 67 68 |
# File 'lib/evil_events/core/events/event_factory.rb', line 66 def restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {}) event_class.new(id: id || UNDEFINED_EVENT_ID, payload: payload, metadata: ) end |
Instance Method Details
#create_abstract_class(event_type) ⇒ Class{EvilEvents::Core::Events::AbstractEvent} (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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/evil_events/core/events/event_factory.rb', line 19 def create_abstract_class(event_type) Class.new(AbstractEvent).tap do |klass| klass.type(event_type) klass.__creation_strategy__ = CLASS_INHERITANCE_STRATEGY class << klass def inherited(child_class) child_class.type(type) child_class.__creation_strategy__ = CLASS_INHERITANCE_STRATEGY child_class.manage! rescue EvilEvents::AlreadyManagedEventClassError EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class) raise end end end end |
#create_class(event_type, &event_class_definitions) {|AbstractEvent| ... } ⇒ Class{EvilEvents::Core::Events::AbstractEvent} (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.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/evil_events/core/events/event_factory.rb', line 44 def create_class(event_type, &event_class_definitions) Class.new(AbstractEvent).tap do |klass| begin klass.__creation_strategy__ = PROC_EVAL_STRATEGY klass.type(event_type) klass.manage! klass.evaluate(&event_class_definitions) if block_given? rescue StandardError EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass) raise end end end |
#restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {}) ⇒ EvilEvents::Core::Events::AbstractEvent (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.
66 67 68 |
# File 'lib/evil_events/core/events/event_factory.rb', line 66 def restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {}) event_class.new(id: id || UNDEFINED_EVENT_ID, payload: payload, metadata: ) end |