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

#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

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#positionObject

Returns the value of attribute position.



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

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

#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

#start_hiddenObject

Returns the value of attribute start_hidden.



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

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

#toggle_shortcutObject

Returns the value of attribute toggle_shortcut.



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

def toggle_shortcut
  @toggle_shortcut
end

#use_existing_jqueryObject

Deprecated options



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

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

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



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mini_profiler/config.rb', line 26

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
    @position               = 'left'  # Where it is displayed
    @skip_schema_queries    = false
    @storage                = MiniProfiler::MemoryStore
    @user_provider          = Proc.new{|env| Rack::Request.new(env).ip}
    @authorization_mode     = :allow_all
    @toggle_shortcut        = 'Alt+P'
    @start_hidden           = false
    @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
    self
  }
end

Instance Method Details

#merge!(config) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/mini_profiler/config.rb', line 55

def merge!(config)
  return unless 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