Class: Debugbar::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/debugbar/engine.rb

Instance Method Summary collapse

Instance Method Details

#log(msg) ⇒ Object



10
11
12
13
# File 'lib/debugbar/engine.rb', line 10

def log(msg)
  @logger ||= Logger.new(STDOUT)
  Array.wrap(msg).each { |m| @logger.warn(m) }
end

#subscribe(config) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/debugbar/engine.rb', line 164

def subscribe(config)
  config.each do |subscriber, event_names|
    event_names = Array.wrap(event_names)
    class_name, class_method_name = subscriber.split('.')
    event_names.each do |name|
      method_name = class_method_name || name.split('.').first
      ActiveSupport::Notifications.subscribe name do |event|
        class_name.constantize.send method_name, event
      end
    end
  end
end