Module: ROM::Notifications::Listener

Included in:
Gateway, Relation::ClassInterface, Schema
Defined in:
lib/rom/support/notifications.rb

Overview

Extension for objects that can listen to events

Instance Method Summary collapse

Instance Method Details

#subscribe(event_id, query = EMPTY_HASH, &block) ⇒ Object

Subscribe to events

Parameters:

  • event_id (String)

    The event key

  • query (Hash) (defaults to: EMPTY_HASH)

    An optional event filter

Returns:

  • (Object)

    self



193
194
195
# File 'lib/rom/support/notifications.rb', line 193

def subscribe(event_id, query = EMPTY_HASH, &block)
  Notifications.listeners[event_id] << [block, query]
end