class Airbrake::FilterChain
Represents the mechanism for filtering notices. Defines a few default filters.
@see Airbrake.add_filter @api private @since v1.0.0
Constants
- DEFAULT_FILTERS
@return [Array<Class>] filters to be executed first
- DEFAULT_WEIGHT
@return [Integer]
Public Class Methods
new()
click to toggle source
# File lib/airbrake-ruby/filter_chain.rb, line 24 def initialize @filters = [] DEFAULT_FILTERS.each { |f| add_filter(f.new) } end
Public Instance Methods
add_filter(filter)
click to toggle source
Adds a filter to the filter chain. Sorts filters by weight.
@param [#call] filter The filter object (proc, class, module, etc) @return [void]
# File lib/airbrake-ruby/filter_chain.rb, line 34 def add_filter(filter) @filters = (@filters << filter).sort_by do |f| f.respond_to?(:weight) ? f.weight : DEFAULT_WEIGHT end.reverse! end
refine(notice)
click to toggle source
Applies all the filters in the filter chain to the given notice. Does not filter ignored notices.
@param [Airbrake::Notice] notice The notice to be filtered @return [void]
# File lib/airbrake-ruby/filter_chain.rb, line 46 def refine(notice) @filters.each do |filter| break if notice.ignored? filter.call(notice) end end