Module: Hippo::Concerns::PubSub

Extended by:
ActiveSupport::Concern
Included in:
Model
Defined in:
lib/hippo/concerns/pub_sub.rb

Overview

Event subscription and publishing for Models Every model has certain built-in events (:save, :create, :update, :destroy) And may also implement custom events that reflect the models domain

Examples:

Send an email when a customer’s name is updated

Customer.observe(:update) do |customer|
    Mailer.notify_billing(customer).deliver if customer.name_changed?
end

Update some stats when a Sku’s qty is changed

Sku.observe(:qty_changed) do | sku, location, old_qty, new_qty |
    Stats.refresh( location )
end

Defined Under Namespace

Modules: ClassMethods, PendingListeners Classes: InvalidEvent