Module: Peastash::Watch

Defined in:
lib/peastash/rails_ext/watch.rb

Instance Method Summary collapse

Instance Method Details

#watch(event, opts = {}, &block) ⇒ Object



5
6
7
8
9
10
11
# 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