Cqrs::Core
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/cqrs/core
. To experiment with that code, run bin/console
for an interactive prompt.
TODO: Delete this and the text above, and describe your gem
Installation
Add this line to your application's Gemfile:
gem 'nexus_cqrs'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install nexus_cqrs
Usage
Generators can be used to aide in the creation of Commands and Queries:
rails g nexus_cqrs:command CommandName
rails g nexus_cqrs:query QueryName
Once installed, a CommandBus is required to control the flow of Commands and/or Queries:
Middleware
Middleware can be created by extending the base middleware:
class MyMiddleware < NexusCqrs::BaseMiddleware
def call(command)
@next.call(command)
end
end
The above middleware will pass responsibility for execution to the next responder in the chain.
For more information on writing middleware see: https://github.com/Ibsciss/ruby-middleware
When creating a bus, middleware can be attached like so:
middleware_stack = Middleware::Builder.new do |b|
b.use MyMiddleware
end
command_bus = Bus.new(middleware: middleware_stack)
Development
To contribute to this gem, simple pull the repository, run bundle install
and run tests:
bundle exec rspec
bundle exec rubocop
Releasing
The release process is tied to the git tags. Simply creating a new tag and pushing will trigger a new release to reubygems.