Class: Rack::MiniProfiler::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_profiler/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorization_modeObject

Returns the value of attribute authorization_mode.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def authorization_mode
  @authorization_mode
end

#auto_injectObject

Returns the value of attribute auto_inject.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def auto_inject
  @auto_inject
end

#backtrace_ignoresObject

Returns the value of attribute backtrace_ignores.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def backtrace_ignores
  @backtrace_ignores
end

#backtrace_includesObject

Returns the value of attribute backtrace_includes.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def backtrace_includes
  @backtrace_includes
end

#backtrace_removeObject

Returns the value of attribute backtrace_remove.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def backtrace_remove
  @backtrace_remove
end

#backtrace_threshold_msObject

Returns the value of attribute backtrace_threshold_ms.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def backtrace_threshold_ms
  @backtrace_threshold_ms
end

#base_url_pathObject

Returns the value of attribute base_url_path.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def base_url_path
  @base_url_path
end

#collapse_resultsObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def collapse_results
  @collapse_results
end

#disable_cachingObject

Returns the value of attribute disable_caching.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def disable_caching
  @disable_caching
end

#disable_env_dumpObject

Returns the value of attribute disable_env_dump.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def disable_env_dump
  @disable_env_dump
end

#enabledObject

Returns the value of attribute enabled.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def enabled
  @enabled
end

#flamegraph_sample_rateObject

Returns the value of attribute flamegraph_sample_rate.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def flamegraph_sample_rate
  @flamegraph_sample_rate
end

#horizontal_positionObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def horizontal_position
  @horizontal_position
end

#html_containerObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def html_container
  @html_container
end

#loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def logger
  @logger
end

#max_sql_param_lengthObject

Returns the value of attribute max_sql_param_length.



21
22
23
# File 'lib/mini_profiler/config.rb', line 21

def max_sql_param_length
  @max_sql_param_length
end

#max_traces_to_showObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def max_traces_to_show
  @max_traces_to_show
end

#positionObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def position
  @position
end

#pre_authorize_cbObject

Returns the value of attribute pre_authorize_cb.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def pre_authorize_cb
  @pre_authorize_cb
end

#show_childrenObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def show_children
  @show_children
end

#show_controlsObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def show_controls
  @show_controls
end

#show_trivialObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def show_trivial
  @show_trivial
end

#skip_pathsObject

Returns the value of attribute skip_paths.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def skip_paths
  @skip_paths
end

#skip_schema_queriesObject

Returns the value of attribute skip_schema_queries.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def skip_schema_queries
  @skip_schema_queries
end

#skip_sql_param_namesObject

Returns the value of attribute skip_sql_param_names.



21
22
23
# File 'lib/mini_profiler/config.rb', line 21

def skip_sql_param_names
  @skip_sql_param_names
end

#start_hiddenObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def start_hidden
  @start_hidden
end

#storageObject

Returns the value of attribute storage.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage
  @storage
end

#storage_failureObject

Returns the value of attribute storage_failure.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage_failure
  @storage_failure
end

#storage_instanceObject

Returns the value of attribute storage_instance.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage_instance
  @storage_instance
end

#storage_optionsObject

Returns the value of attribute storage_options.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage_options
  @storage_options
end

#suppress_encodingObject

Returns the value of attribute suppress_encoding.



21
22
23
# File 'lib/mini_profiler/config.rb', line 21

def suppress_encoding
  @suppress_encoding
end

#toggle_shortcutObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def toggle_shortcut
  @toggle_shortcut
end

#use_existing_jqueryObject

Deprecated options



29
30
31
# File 'lib/mini_profiler/config.rb', line 29

def use_existing_jquery
  @use_existing_jquery
end

#user_providerObject

Returns the value of attribute user_provider.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def user_provider
  @user_provider
end

#vertical_positionObject

ui accessors



24
25
26
# File 'lib/mini_profiler/config.rb', line 24

def vertical_position
  @vertical_position
end

Class Method Details

.attr_accessor(*vars) ⇒ Object



5
6
7
8
9
# File 'lib/mini_profiler/config.rb', line 5

def self.attr_accessor(*vars)
  @attributes ||= []
  @attributes.concat vars
  super(*vars)
end

.attributesObject



11
12
13
# File 'lib/mini_profiler/config.rb', line 11

def self.attributes
  @attributes
end

.defaultObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mini_profiler/config.rb', line 31

def self.default
  new.instance_eval {
    @auto_inject      = true # automatically inject on every html page
    @base_url_path    = "/mini-profiler-resources/"
    @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
    @storage_failure = Proc.new do |exception|
      if @logger
        @logger.warn("MiniProfiler storage failure: #{exception.message}")
      end
    end
    @enabled = true
    @disable_env_dump = false
    @max_sql_param_length = 0 # disable sql parameter collection by default
    @skip_sql_param_names = /password/ # skips parameters with the name password by default

    # ui parameters
    @autorized          = true
    @collapse_results   = true
    @max_traces_to_show = 20
    @show_children      = false
    @show_controls      = false
    @show_trivial       = false
    @start_hidden       = false
    @toggle_shortcut    = 'Alt+P'
    @html_container     = 'body'

    self
  }
end

Instance Method Details

#merge!(config) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/mini_profiler/config.rb', line 71

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
  set_positions!
end

#set_positions!Object



85
86
87
88
89
# File 'lib/mini_profiler/config.rb', line 85

def set_positions!
  position = (self.position && self.position.match("-")) ? self.position.split("-") : ["top", "left"]
  self.vertical_position = position.first
  self.horizontal_position = position.last
end