Class: Debugbar::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
14
15
16
17
18
# File 'lib/debugbar/config.rb', line 9

def initialize(options = {})
  opt = defaults.merge options
  @enabled = opt[:enabled] && !defined?(Rails::Console)
  @prefix = opt[:prefix]
  @active_record = opt[:active_record]
  @action_controller = opt[:action_controller]
  @active_job = opt[:active_job]
  @min_log_level = opt[:min_log_level]
  @buffer_adapter = opt[:buffer_adapter]
end

Instance Attribute Details

#action_controllerObject

Returns the value of attribute action_controller.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def action_controller
  @action_controller
end

#active_jobObject

Returns the value of attribute active_job.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def active_job
  @active_job
end

#active_recordObject

Returns the value of attribute active_record.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def active_record
  @active_record
end

#buffer_adapterObject

Returns the value of attribute buffer_adapter.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def buffer_adapter
  @buffer_adapter
end

#enabledObject Also known as: enabled?

Returns the value of attribute enabled.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def enabled
  @enabled
end

#ignore_requestObject

Returns the value of attribute ignore_request.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def ignore_request
  @ignore_request
end

#min_log_levelObject

Returns the value of attribute min_log_level.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def min_log_level
  @min_log_level
end

#prefixObject

Returns the value of attribute prefix.



3
4
5
# File 'lib/debugbar/config.rb', line 3

def prefix
  @prefix
end

Instance Method Details

#defaultsObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/debugbar/config.rb', line 20

def defaults
  {
    enabled: Rails.env.development?,
    prefix: "/_debugbar",
    active_record: true,
    action_controller: true,
    active_job: true,
    min_log_level: -1,
    buffer_adapter: :memory,
  }
end

#ignore_request?(env) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
# File 'lib/debugbar/config.rb', line 32

def ignore_request?(env)
  if ignore_request.is_a? Proc
    ignore_request.call(env)
  else
    [Debugbar.config.prefix, "/assets"].any? do |s|
      env['PATH_INFO'].start_with? s
    end || env['REQUEST_METHOD'] == "OPTIONS"
  end
end

#use_logger?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/debugbar/config.rb', line 42

def use_logger?
  @enabled && @min_log_level >= 0
end