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

Extended by:
Dry::Core::ClassAttributes
Defined in:
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


18
19
20
21
22
23
24
# File 'lib/rom/plugins/relation/instrumentation.rb', line 18

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


50
51
52
# File 'lib/rom/plugins/relation/instrumentation.rb', line 50

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