Sha256: 88d44862ec098a44062cbb3336f748522f3c4632e0f3e40ec43dbda0c34130c9

Contents?: true

Size: 607 Bytes

Versions: 16

Compression:

Stored size: 607 Bytes

Contents

module NotificationHelpers
  def with_subscription_to(matcher, notification_callable)
    subscription = ActiveSupport::Notifications.subscribe(matcher, notification_callable)
    yield
  ensure
    ActiveSupport::Notifications.unsubscribe(subscription)
  end

  def listeners_for(event_name)
    ActiveSupport::Notifications.notifier.listeners_for(event_name)
  end

  def subscribers_for(event_name)
    listeners_for(event_name).map{ |listener|
      listener.instance_variable_get('@delegate')
    }
  end

  def subscriber_classes_for(event_name)
    subscribers_for(event_name).map(&:class)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
paul_bunyan-2.1.0 spec/support/notification_helpers.rb
paul_bunyan-2.0.0 spec/support/notification_helpers.rb
paul_bunyan-1.6.0 spec/support/notification_helpers.rb
paul_bunyan-1.5.3 spec/support/notification_helpers.rb
paul_bunyan-1.5.2 spec/support/notification_helpers.rb
paul_bunyan-1.5.1 spec/support/notification_helpers.rb
paul_bunyan-1.5.0 spec/support/notification_helpers.rb
paul_bunyan-1.4.0 spec/support/notification_helpers.rb
paul_bunyan-1.3.0 spec/support/notification_helpers.rb
paul_bunyan-1.2.3 spec/support/notification_helpers.rb
paul_bunyan-1.2.2 spec/support/notification_helpers.rb
paul_bunyan-1.2.1 spec/support/notification_helpers.rb
paul_bunyan-1.2.0 spec/support/notification_helpers.rb
paul_bunyan-1.1.0 spec/support/notification_helpers.rb
paul_bunyan-1.0.1 spec/support/notification_helpers.rb
paul_bunyan-1.0.0 spec/support/notification_helpers.rb