Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Projections

Andreas Reischuck edited this page Sep 11, 2013 · 3 revisions

Generally spoken, projections are some sort of container for event handlers of the published events from the domain server.
Same as for models, they also live in two environments. On the one hand, there are the standard projections on the projection server, which update their specific projection model and on the other hand, there is the domain projection. The domain projection cares about updating the domain model.

Codewise they are pretty similar, except for their includings. Standard projections should include the ActiveProjection::ProjectionType module and the domain projection should include ActiveDomain::Projection.

The public methods of the projections should be named exact like the underscore notation of the event they handle. For example take a PostCreateEvent, then the code should be:

def post_create_event(event)
  #do stuff with the event, like "Post.create!"
end

The directories for the projections are app/projections and domain/projections.

Clone this wiki locally