Class: ROM::Notifications::EventBus

Inherits:
Object
  • Object
show all
Includes:
Publisher
Defined in:
lib/rom/support/notifications.rb

Overview

Event bus

An event bus stores listeners (callbacks) and events

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Publisher

#subscribe, #trigger

Constructor Details

#initialize(id, events: EMPTY_HASH, listeners: LISTENERS_HASH.dup) ⇒ EventBus

Initialize a new event bus

Parameters:

  • id (Symbol) —

    The bus identifier

  • events (Hash) (defaults to: EMPTY_HASH) —

    A hash with events

  • listeners (Hash) (defaults to: LISTENERS_HASH.dup) —

    A hash with listeners



221
222
223
224
225
# File 'lib/rom/support/notifications.rb', line 221

def initialize(id, events: EMPTY_HASH, listeners: LISTENERS_HASH.dup)
  @id = id
  @listeners = listeners
  @events = events
end

Instance Attribute Details

#events ⇒ Object (readonly)



208
209
210
# File 'lib/rom/support/notifications.rb', line 208

def events
  @events
end

#id ⇒ Object (readonly)



204
205
206
# File 'lib/rom/support/notifications.rb', line 204

def id
  @id
end

#listeners ⇒ Object (readonly)



212
213
214
# File 'lib/rom/support/notifications.rb', line 212

def listeners
  @listeners
end