Sha256: ed7aedefd15f147dc885c0dcd85fe652fd81b5213ec5da72ce3de68bfae12132

Contents?: true

Size: 714 Bytes

Versions: 10

Compression:

Stored size: 714 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(view_context, &block)
      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

10 entries across 10 versions & 1 rubygems

Version Path
view_component-3.12.1 lib/view_component/instrumentation.rb
view_component-3.12.0 lib/view_component/instrumentation.rb
view_component-3.11.0 lib/view_component/instrumentation.rb
view_component-3.10.0 lib/view_component/instrumentation.rb
view_component-3.9.0 lib/view_component/instrumentation.rb
view_component-3.8.0 lib/view_component/instrumentation.rb
view_component-3.7.0 lib/view_component/instrumentation.rb
view_component-3.6.0 lib/view_component/instrumentation.rb
view_component-3.5.0 lib/view_component/instrumentation.rb
view_component-3.4.0 lib/view_component/instrumentation.rb