Class: Debugbar::Config
- Inherits:
-
Object
- Object
- Debugbar::Config
- Defined in:
- lib/debugbar/config.rb
Instance Attribute Summary collapse
-
#action_controller ⇒ Object
Returns the value of attribute action_controller.
-
#active_job ⇒ Object
Returns the value of attribute active_job.
-
#active_record ⇒ Object
Returns the value of attribute active_record.
-
#buffer_adapter ⇒ Object
Returns the value of attribute buffer_adapter.
-
#enabled ⇒ Object
(also: #enabled?)
Returns the value of attribute enabled.
-
#ignore_request ⇒ Object
Returns the value of attribute ignore_request.
-
#min_log_level ⇒ Object
Returns the value of attribute min_log_level.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
- #defaults ⇒ Object
- #ignore_request?(env) ⇒ Boolean
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #use_logger? ⇒ Boolean
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( = {}) opt = defaults.merge @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_controller ⇒ Object
Returns the value of attribute action_controller.
3 4 5 |
# File 'lib/debugbar/config.rb', line 3 def action_controller @action_controller end |
#active_job ⇒ Object
Returns the value of attribute active_job.
3 4 5 |
# File 'lib/debugbar/config.rb', line 3 def active_job @active_job end |
#active_record ⇒ Object
Returns the value of attribute active_record.
3 4 5 |
# File 'lib/debugbar/config.rb', line 3 def active_record @active_record end |
#buffer_adapter ⇒ Object
Returns the value of attribute buffer_adapter.
3 4 5 |
# File 'lib/debugbar/config.rb', line 3 def buffer_adapter @buffer_adapter end |
#enabled ⇒ Object 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_request ⇒ Object
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_level ⇒ Object
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 |
#prefix ⇒ Object
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/debugbar/config.rb', line 3 def prefix @prefix end |
Instance Method Details
#defaults ⇒ Object
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
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
42 43 44 |
# File 'lib/debugbar/config.rb', line 42 def use_logger? @enabled && @min_log_level >= 0 end |