Module: ROM::Plugins::Relation::Instrumentation

Extended by:
Dry::Core::ClassAttributes
Defined in:
core/lib/rom/plugins/relation/instrumentation.rb

Overview

Experimental plugin for configuring relations with an external instrumentation system like dry-monitor or ActiveSupport::Notifications

Defined Under Namespace

Modules: ClassInterface

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This hooks sets up a relation class with injectible notifications object



16
17
18
19
20
21
22
# File 'core/lib/rom/plugins/relation/instrumentation.rb', line 16

def self.included(klass)
  super
  klass.option :notifications
  klass.extend(ClassInterface)
  klass.prepend(mixin)
  klass.instrument(:to_a)
end

Instance Method Details

#instrument(&block) ⇒ Object

Execute a block using instrumentation



48
49
50
# File 'core/lib/rom/plugins/relation/instrumentation.rb', line 48

def instrument(&block)
  notifications.instrument(self.class.adapter, name: name.relation, **notification_payload(self), &block)
end