module Peastash::Watch

Public Instance Methods

watch(event, opts = {}, &block) click to toggle source
# File lib/peastash/rails_ext/watch.rb, line 5
def watch(event, opts = {}, &block)
  event_group = opts[:event_group] || event
  ActiveSupport::Notifications.subscribe(event) do |*args|
    # Calling the processing block with the Notification args and the store
    block.call(*args, self.store[event_group])
  end
end