Class: Yes::Core::EventClassResolver
- Inherits:
-
Object
- Object
- Yes::Core::EventClassResolver
- Defined in:
- lib/yes/core/event_class_resolver.rb
Overview
Resolves PgEventstore event types back into their proper class. When configured as the event_class_resolver in PgEventstore, events deserialized from the store will be instances of their registered class (e.g., ‘Test::UserCreated < Yes::Core::Event`) instead of raw `PgEventstore::Event`.
Defined Under Namespace
Classes: SkipValidationProxy
Instance Method Summary collapse
-
#call(event_type) ⇒ #new
Resolves an event type string to its class.
Instance Method Details
#call(event_type) ⇒ #new
Resolves an event type string to its class.
29 30 31 32 33 34 35 36 37 |
# File 'lib/yes/core/event_class_resolver.rb', line 29 def call(event_type) SkipValidationProxy.new(Object.const_get(event_type)) rescue NameError, TypeError PgEventstore.logger&.debug(<<~TEXT.strip) Unable to resolve class by `#{event_type}' event type. \ Picking #{Event} event class to instantiate the event. TEXT Event end |