Activeevent
Add domain events to your models.
Installation
Add this line to your application's Gemfile:
gem 'horizon'
And then execute:
$ bundle
Or install it yourself as:
$ gem install horizon
Usage
First, publish some domain events:
class Dog < ActiveRecord::Base
include Horizon::Publisher
def feed
self.hungry = false
publish :dog_fed, self
end
end
Then, handle them:
class DogOwnerNotifier
include Horizon::Handler
def dog_fed(dog)
mail_owner(dog)
end
handler :dog_fed
# or
handler :dog_fed do |dog|
mail_owner(dog)
end
# or
handler dog_fed: :mail_owner
# ...
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request