class Rack::MiniProfiler::Config

Attributes

assets_url[R]
authorization_mode[RW]
auto_inject[RW]
backtrace_ignores[RW]
backtrace_includes[RW]
backtrace_remove[RW]
backtrace_threshold_ms[RW]
base_url_path[RW]
collapse_results[RW]

ui accessors

content_security_policy_nonce[RW]
disable_caching[RW]
enable_advanced_debugging_tools[RW]
enable_hotwire_turbo_drive_support[RW]
enabled[RW]
flamegraph_mode[RW]
flamegraph_sample_rate[RW]
html_container[RW]

ui accessors

logger[RW]
max_snapshot_groups[RW]

snapshot related config

max_snapshots_per_group[RW]

snapshot related config

max_sql_param_length[RW]
max_traces_to_show[RW]

ui accessors

position[RW]

ui accessors

pre_authorize_cb[RW]
profile_parameter[RW]
show_children[RW]

ui accessors

show_controls[RW]

ui accessors

show_total_sql_count[RW]

ui accessors

show_trivial[RW]

ui accessors

skip_paths[RW]
skip_schema_queries[RW]
skip_sql_param_names[RW]
snapshot_every_n_requests[RW]

snapshot related config

snapshot_hidden_custom_fields[RW]

snapshot related config

snapshots_redact_sql_queries[RW]

snapshot related config

snapshots_transport_auth_key[RW]

snapshot related config

snapshots_transport_destination_url[RW]

snapshot related config

snapshots_transport_gzip_requests[RW]

snapshot related config

start_hidden[RW]

ui accessors

storage[RW]
storage_failure[RW]
storage_instance[RW]
storage_options[RW]
suppress_encoding[RW]
toggle_shortcut[RW]

ui accessors

use_existing_jquery[RW]

Deprecated options

user_provider[RW]

Public Class Methods

attr_accessor(*vars) click to toggle source
Calls superclass method
# File lib/mini_profiler/config.rb, line 6
def self.attr_accessor(*vars)
  @attributes ||= []
  @attributes.concat vars
  super(*vars)
end
attributes() click to toggle source
# File lib/mini_profiler/config.rb, line 12
def self.attributes
  @attributes
end
default() click to toggle source
# File lib/mini_profiler/config.rb, line 16
def self.default
  new.instance_eval {
    @auto_inject      = true # automatically inject on every html page
    @base_url_path    = "/mini-profiler-resources/".dup
    @cookie_path      = "/".dup
    @disable_caching  = true
    # called prior to rack chain, to ensure we are allowed to profile
    @pre_authorize_cb = lambda { |env| true }

    # called after rack chain, to ensure we are REALLY allowed to profile
    @skip_schema_queries    = false
    @storage                = MiniProfiler::MemoryStore
    @user_provider          = Proc.new { |env| Rack::Request.new(env).ip }
    @authorization_mode     = :allow_all
    @backtrace_threshold_ms = 0
    @flamegraph_sample_rate = 0.5
    @flamegraph_mode = :wall
    @storage_failure = Proc.new do |exception|
      if @logger
        @logger.warn("MiniProfiler storage failure: #{exception.message}")
      end
    end
    @enabled = true
    @max_sql_param_length = 0 # disable sql parameter collection by default
    @skip_sql_param_names = /password/ # skips parameters with the name password by default
    @enable_advanced_debugging_tools = false
    @snapshot_every_n_requests = -1
    @max_snapshot_groups = 50
    @max_snapshots_per_group = 15

    # ui parameters
    @autorized            = true
    @collapse_results     = true
    @max_traces_to_show   = 20
    @show_children        = false
    @show_controls        = false
    @show_trivial         = false
    @show_total_sql_count = false
    @start_hidden         = false
    @toggle_shortcut      = 'alt+p'
    @html_container       = 'body'
    @position             = "top-left"
    @snapshot_hidden_custom_fields = []
    @snapshots_transport_destination_url = nil
    @snapshots_transport_auth_key = nil
    @snapshots_redact_sql_queries = true
    @snapshots_transport_gzip_requests = false
    @enable_hotwire_turbo_drive_support = false

    @profile_parameter = "pp"

    self
  }
end

Public Instance Methods

assets_url=(lmbda) click to toggle source
# File lib/mini_profiler/config.rb, line 113
def assets_url=(lmbda)
  if defined?(Rack::MiniProfilerRails)
    Rack::MiniProfilerRails.create_engine
  end
  @assets_url = lmbda
end
authorization_mode=(mode) click to toggle source
# File lib/mini_profiler/config.rb, line 99
      def authorization_mode=(mode)
        if mode == :whitelist
          warn "[DEPRECATION] `:whitelist` authorization mode is deprecated. Please use `:allow_authorized` instead."

          mode = :allow_authorized
        end

        warn <<~DEP unless mode == :allow_authorized || mode == :allow_all
          [DEPRECATION] unknown authorization mode #{mode}. Expected `:allow_all` or `:allow_authorized`.
        DEP

        @authorization_mode = mode
      end
horizontal_position() click to toggle source
# File lib/mini_profiler/config.rb, line 124
def horizontal_position
  position.include?('right') ? 'right' : 'left'
end
merge!(config) click to toggle source
# File lib/mini_profiler/config.rb, line 128
def merge!(config)
  if config
    if Hash === config
      config.each { |k, v| instance_variable_set "@#{k}", v }
    else
      self.class.attributes.each { |k|
        v = config.send k
        instance_variable_set "@#{k}", v if v
      }
    end
  end
end
vertical_position() click to toggle source
# File lib/mini_profiler/config.rb, line 120
def vertical_position
  position.include?('bottom') ? 'bottom' : 'top'
end