Sha256: dc32bab124538a659d91a86048bf3df9fab32e90f5141988c6654b89672fa73e

Contents?: true

Size: 554 Bytes

Versions: 2

Compression:

Stored size: 554 Bytes

Contents

module Phobos
  module Instrumentation
    NAMESPACE = 'phobos'

    def instrument(event, extra = {})
      ActiveSupport::Notifications.instrument("#{NAMESPACE}.#{event}", extra) do
        yield if block_given?
      end
    end

    def self.subscribe(event)
      ActiveSupport::Notifications.subscribe("#{NAMESPACE}.#{event}") do |*args|
        yield ActiveSupport::Notifications::Event.new(*args) if block_given?
      end
    end

    def self.unsubscribe(subscriber)
      ActiveSupport::Notifications.unsubscribe(subscriber)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phobos-1.1.0 lib/phobos/instrumentation.rb
phobos-1.0.0 lib/phobos/instrumentation.rb