Sha256: c9ed98e84be8aa4ef53931782e6aff323c1ce9279aab198be2653290f70d5fe4

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 Bytes

Contents

# frozen_string_literal: true

module FactoryBot
  module Instrumentation
    # The Instrumentation engine which can be mounted.
    class Engine < ::Rails::Engine
      isolate_namespace FactoryBot::Instrumentation

      # Fill in some dynamic settings (application related)
      initializer 'factory_bot_instrumentation.config' do
        # Ensure the FactoryBot gem loads its factories to ensure they are
        # also available in the rails console and other places in the app
        # and not only via instrumentation frontend.
        FactoryBot.reload

        FactoryBot::Instrumentation.configure do |conf|
          # Set the application name dynamically
          conf.application_name ||= begin
            app_class = Rails.application.class
            parent_name = app_class.module_parent_name \
              if app_class.respond_to?(:module_parent_name)
            parent_name ||= app_class.parent_name
            parent_name.titleize
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
factory_bot_instrumentation-1.0.1 lib/factory_bot/instrumentation/engine.rb
factory_bot_instrumentation-1.0.0 lib/factory_bot/instrumentation/engine.rb