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.
16 17 18 |
# File 'lib/yell/silencer.rb', line 16 def initialize( *patterns ) @patterns = patterns.dup end |
Instance Method Details
#add(*patterns) ⇒ self
Add one or more patterns to the silencer
30 31 32 33 34 |
# File 'lib/yell/silencer.rb', line 30 def add( *patterns ) patterns.each { |pattern| add!(pattern) } self end |
#call(*messages) ⇒ Array
Clears out all the messages that would match any defined pattern
43 44 45 46 47 |
# File 'lib/yell/silencer.rb', line 43 def call( * ) return if @patterns.empty? .reject { |m| matches?(m) } end |
#inspect ⇒ Object
Get a pretty string
50 51 52 |
# File 'lib/yell/silencer.rb', line 50 def inspect "#<#{self.class.name} patterns: #{@patterns.inspect}>" end |
#patterns ⇒ Object
55 56 57 |
# File 'lib/yell/silencer.rb', line 55 def patterns @patterns end |