Sha256: 1a8cfe8860e0e588b78c9b12efec920c748dda1a6f03b52705117d9552b99b17

Contents?: true

Size: 1.81 KB

Versions: 18

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

module FactoryBot
  module Instrumentation
    # The configuration for the instrumentation API.
    class Configuration
      include ActiveSupport::Configurable

      # The instrumentation configuration file path we should use,
      # defaults to config/instrumentation.yml
      config_accessor(:config_file) do
        'config/instrumentation.yml'
      end

      # You can set a fixed application name here,
      # defaults to your Rails application name in a titlized version
      config_accessor(:application_name) { nil }

      # By default we use the Rails default JSON rendering mechanism, but
      # you can configure your own logic here
      config_accessor(:render_entity) do
        proc do |controller, entity|
          controller.render plain: entity.to_json,
                            content_type: 'application/json'
        end
      end

      # By default we assemble a JSON response on errors which may be
      # helpful for debugging, but you can configure your own logic here
      config_accessor(:render_error) do
        proc do |controller, error|
          app_name = FactoryBot::Instrumentation.configuration.application_name
          controller.render status: :internal_server_error,
                            content_type: 'application/json',
                            plain: {
                              application: app_name,
                              error: error.message,
                              backtrace: error.backtrace.join("\n")
                            }.to_json
        end
      end

      # By default we do not perform any custom +before_action+ filters on the
      # instrumentation controllers, with this option you can implement your
      # custom logic like authentication
      config_accessor(:before_action) { nil }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
factory_bot_instrumentation-1.2.4 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.2.3 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.2.2 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.2.1 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.2.0 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.1.5 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.1.4 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.1.3 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.1.2 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.1.1 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.1.0 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.0.2 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.0.1 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-1.0.0 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-0.8.0 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-0.7.1 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-0.7.0 lib/factory_bot/instrumentation/configuration.rb
factory_bot_instrumentation-0.6.0 lib/factory_bot/instrumentation/configuration.rb