Class: TypedCache::Instrumenters::ActiveSupport

Inherits:
Object
  • Object
show all
Includes:
TypedCache::Instrumenter, Mixins::NamespacedSingleton
Defined in:
lib/typed_cache/instrumenters/active_support.rb

Overview

Instrumenter for ActiveSupport::Notifications

Instance Method Summary collapse

Methods included from Mixins::NamespacedSingleton

all, included, #initialize, #namespace

Methods included from TypedCache::Instrumenter

#enabled?, #namespace

Instance Method Details

#instrument(operation, key, **payload, &block) ⇒ Object

: [R] (String, String, Hash[Symbol, untyped]) { -> R } -> R



14
15
16
17
18
19
# File 'lib/typed_cache/instrumenters/active_support.rb', line 14

def instrument(operation, key, **payload, &block)
  return yield unless enabled?

  payload = build_payload(operation, key, **payload)
  ::ActiveSupport::Notifications.instrument(event_name(operation), **payload, &block)
end

#subscribe(operation, **filters, &block) ⇒ Object



23
24
25
# File 'lib/typed_cache/instrumenters/active_support.rb', line 23

def subscribe(operation, **filters, &block)
  ::ActiveSupport::Notifications.monotonic_subscribe(event_name(operation), &block)
end