This is Gem is for ruby projects which are using DDD tactical design. It provides some basic classes. You can derive from them and stop thinking about some basic redundant implementations. It also provides some event infrastructure handling.
In the near future there will be examples on how to use it in your project.
class ExampleAggregateRoot < DDDTooling::Aggregate
end
class ExampleEntity < DDDTooling::Entity
end
class ExampleValueObject < DDDTooling::ValueObject
end
provides a unique_identifer
and a occured_at
timestamp
class ExampleDomainEvent < DDDTooling::Event
end
It provides a simple event store. You can store and replay events. It provides the following methods:
store(event:)
- stores an eventstored_events
- returns all stored eventsreplay_events
- replays all stored events
class ExampleEventStore < DDDTooling::Infrastructure::EventStore
end
It provides a simple event dispatcher. You can register event handlers and dispatch events. You can register event handlers for specific events. You should use a dependency injection container to register the event dispatcher as a singleton. It provides the following methods:
subscribe(event_class:, subscriber_class:)
- registers a subscriber for a specific eventdispatch(event:)
- dispatches an event to all subscribersdispatch_all(events:)
- dispatches all events to all subscribers
class ExampleEventDispatcher < DDDTooling::Infrastructure::EventDispatcher
end
It provides a simple event committer. You can commit events to the event store and dispatch them to the event dispatcher. It takes also the event composer as a dependency.
It provides the following methods:
commit(event:)
- commits an event to the event store and when it is saved then dispatches it to the event dispatcher
class ExampleEventCommitter < DDDTooling::Infrastructure::EventCommitter
end
It provides a simple event composer. You can compose events from your domain objects and dispatch them to the event committer which handles the middleware of storing and dispatching the events.
It provides the following methods:
compose(event:)
- composes an event and dispatches it to the event committercompose_all(events:)
- composes all events and dispatches them to the event committeruncommitted_events
- returns all uncommitted eventsclear
- clears all uncommitted events
class ExampleEventComposer < DDDTooling::Infrastructure::EventComposer
end
Bug reports and pull requests are welcome on GitHub at https://github.com/philwi/ddd_tooling. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the DDDTooling project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.