Gem that provides infrastructure for ruby.
Add this line to your application's Gemfile:
gem 'pavlov'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pavlov
Inspiration: http://www.confreaks.com/videos/759-rubymidwest2011-keynote-architecture-the-lost-years http://martinfowler.com/bliki/CQRS.html
Frontend only calls interactors. Interactors call queries and commands. Queries never call commands, they can call queries. Commands can call commands and queries. But keep your design simple (KISS).
TODO
There are multiple facets to whether a user is authorized:
- Can this user execute this operation
- On which set of objects can this user execute this operation
We decided that the best way to handle this is:
The interactors check whether an operation is authorized before running the execution code, but not in the initialization. This is not implemented yet, but will mean an interactor has something like run which does authorize; execute.
When a operation is executed on one object and this is not authorized, this is clearly an exceptional situation (in the sense that it shouldn't happen), and an exception is thrown.
When a operation is executed on a set of objects, the operation will only execute on the subset the user is authorized for.
These objects can be used to simplify your design by making sure your object is always valid.
class User < Pavlov::Entity do
attributes :name, :username, :email
end
my_entitiy = User.new do
self.name = 'jan'
self.username = 'jjoos'
self.email = '[email protected]'
end
or
my_entitiy = User.new({name: 'jan', username: 'jjoos', email: '[email protected]'})
my_entity = my_entity.update({name: 'joop', email: '[email protected]'})
puts my_entity.username
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Run bundle, before starting development.
- Implement your feature/bugfix and corresponding tests.
- Make sure your tests run against the latest stable mri.
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request