Sha256: 896b0d941bf85fe96fff03f65971c6e4ce21e4057a1775b00240bd06279b7ddf

Contents?: true

Size: 941 Bytes

Versions: 14

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

module Spree
  module Event
    module Adapters
      module ActiveSupportNotifications
        extend self

        def fire(event_name, opts)
          ActiveSupport::Notifications.instrument event_name, opts do
            yield opts if block_given?
          end
        end

        def subscribe(event_name)
          ActiveSupport::Notifications.subscribe event_name do |*args|
            event = ActiveSupport::Notifications::Event.new(*args)
            yield event
          end
        end

        def unsubscribe(subscriber_or_name)
          ActiveSupport::Notifications.unsubscribe(subscriber_or_name)
        end

        def listeners_for(names)
          names.each_with_object({}) do |name, memo|
            listeners = ActiveSupport::Notifications.notifier.listeners_for(name)
            memo[name] = listeners if listeners.present?
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
solidus_core-2.10.5 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.10.3 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.10.2 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.6 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.10.1 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.5 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.10.0 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.4 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.3 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.2 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.10.0.beta1 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.1 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.0 lib/spree/event/adapters/active_support_notifications.rb
solidus_core-2.9.0.rc.1 lib/spree/event/adapters/active_support_notifications.rb