module Wisper::ActiveRecord::Publisher

ActiveRecord extension to automatically publish events for CRUD lifecycle see github.com/krisleech/wisper/wiki/Rails-CRUD-with-ActiveRecord see github.com/krisleech/wisper-activerecord

Private Instance Methods

broadcast_create() click to toggle source

broadcast MODEL_created event to subscribed listeners

# File lib/wisper/activerecord/publisher.rb, line 27
def broadcast_create
  broadcast broadcast_event_name(:created), self
end
broadcast_destroy() click to toggle source

broadcast MODEL_destroyed to subscribed listeners pass a serialized version of the object attributes for listeners since the object is no longer accessible in the database

# File lib/wisper/activerecord/publisher.rb, line 41
def broadcast_destroy
  broadcast broadcast_event_name(:destroyed), attributes
end
broadcast_event_name(lifecycle) click to toggle source
# File lib/wisper/activerecord/publisher.rb, line 45
def broadcast_event_name(lifecycle)
  "#{self.class.model_name.param_key}_#{lifecycle}"
end
broadcast_update() click to toggle source

broadcast MODEL_updated event to subscribed listeners pass the set of changes for background jobs to know what changed see github.com/krisleech/wisper-activerecord/issues/17

# File lib/wisper/activerecord/publisher.rb, line 34
def broadcast_update
  broadcast broadcast_event_name(:updated), self, previous_changes
end