Class: Yell::Silencer
- Inherits:
-
Object
- Object
- Yell::Silencer
- Defined in:
- lib/yell/silencer.rb
Overview
The Yell::Silencer
is your handly helper for stiping out unwanted log messages.
Defined Under Namespace
Classes: PresetNotFound
Constant Summary collapse
- Presets =
{ :assets => [/\AStarted GET "\/assets/, /\AServed asset/, /\A\s*\z/] # for Rails }
Instance Method Summary collapse
-
#add(*patterns) ⇒ self
Add one or more patterns to the silencer.
-
#call(*messages) ⇒ Array
Clears out all the messages that would match any defined pattern.
-
#initialize(*patterns) ⇒ Silencer
constructor
A new instance of Silencer.
-
#inspect ⇒ Object
Get a pretty string.
- #patterns ⇒ Object
Constructor Details
#initialize(*patterns) ⇒ Silencer
Returns a new instance of Silencer.
15 16 17 |
# File 'lib/yell/silencer.rb', line 15 def initialize( *patterns ) @patterns = patterns.dup end |
Instance Method Details
#add(*patterns) ⇒ self
Add one or more patterns to the silencer
29 30 31 32 33 |
# File 'lib/yell/silencer.rb', line 29 def add( *patterns ) patterns.each { |pattern| add!(pattern) } self end |
#call(*messages) ⇒ Array
Clears out all the messages that would match any defined pattern
42 43 44 45 46 |
# File 'lib/yell/silencer.rb', line 42 def call( * ) return if @patterns.empty? .reject { |m| matches?(m) } end |
#inspect ⇒ Object
Get a pretty string
49 50 51 |
# File 'lib/yell/silencer.rb', line 49 def inspect "#<#{self.class.name} patterns: #{@patterns.inspect}>" end |
#patterns ⇒ Object
54 55 56 |
# File 'lib/yell/silencer.rb', line 54 def patterns @patterns end |