Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ventouse/suppress_logging_for.rb

Class Method Summary collapse

Class Method Details

.suppress_logging_for(*actions) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ventouse/suppress_logging_for.rb', line 3

def self.suppress_logging_for *actions
  unless respond_to? :actions_without_logging
    cattr_accessor :actions_without_logging

    self.actions_without_logging = []

    define_method :process do |request, *args|
      if self.class.actions_without_logging.include?((request['action'] || 'index').to_sym)
        logger.silence { super }
      else
        super
      end
    end
  end
  self.actions_without_logging.concat actions.flatten
end