Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

substantial/horizon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Horizon

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages