class Sapience::Extensions::Notifications

Attributes

metric_name[R]
tags[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/sapience/extensions/notifications.rb, line 28
def initialize(options = {})
  @tags = options[:tags] || []
end
subscribe(pattern, &block) click to toggle source
# File lib/sapience/extensions/notifications.rb, line 18
def self.subscribe(pattern, &block)
  if defined?(ActiveSupport::Notifications)
    ::ActiveSupport::Notifications.subscribe(pattern) do |*args|
      block.call ::ActiveSupport::Notifications::Event.new(*args)
    end
  else
    warn "ActiveSupport not available"
  end
end
use(options = {}) click to toggle source
# File lib/sapience/extensions/notifications.rb, line 14
def self.use(options = {})
  new(options)
end

Public Instance Methods

metrics() click to toggle source
# File lib/sapience/extensions/notifications.rb, line 36
def metrics
  Sapience.metrics
end
record?() click to toggle source
# File lib/sapience/extensions/notifications.rb, line 32
def record?
  !metrics.nil?
end