Sha256: a0817538e56835d87194a54fdcf1557f366687a2fde90cb6a8b141e1daba832d

Contents?: true

Size: 692 Bytes

Versions: 3

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

require "active_support/notifications"

module ViewComponent # :nodoc:
  module Instrumentation
    def self.included(mod)
      mod.prepend(self) unless ancestors.include?(ViewComponent::Instrumentation)
    end

    def render_in(view_context, &block)
      ActiveSupport::Notifications.instrument(
        notification_name,
        {
          name: self.class.name,
          identifier: self.class.identifier
        }
      ) do
        super
      end
    end

    private

    def notification_name
      return "!render.view_component" if ViewComponent::Base.config.use_deprecated_instrumentation_name

      "render.view_component"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
view_component-3.21.0 lib/view_component/instrumentation.rb
view_component-3.14.0 lib/view_component/instrumentation.rb
view_component-3.13.0 lib/view_component/instrumentation.rb