class Airbrake::FilterChain

@since v1.0.0
@api private
@see Airbrake.add_filter
#=> Filtering…
filter_chain.refine(obj)
filter_chain.add_filter(MyFilter)
filter_chain = FilterChain.new<br><br>end<br>end<br>obj = ‘[Filtered]’
puts ‘Filtering…’
def call(obj)
end
@weight = 1
def initialize
attr_reader :weight
class MyFilter
@example
weight, the chain assumes it’s equal to 0.
beginning of the array. Larger - in the end. If a filter doesn’t implement
weight. Smaller weight means the filter will be somewhere in the
When you add a new filter to the chain, it gets inserted according to its
exactly one argument: an object to be filtered.
class that implements the call method). The #call method must accept
A filter is an object that responds to #call (typically a Proc or a
FilterChain represents an ordered array of filters.

def add_filter(filter)

Returns:
  • (void) -

Parameters:
  • filter (#call) -- The filter object (proc, class, module, etc)
def add_filter(filter)
  @filters = (@filters << filter).sort_by do |f|
    f.respond_to?(:weight) ? f.weight : DEFAULT_WEIGHT
  end.reverse!
end

def delete_filter(filter_class)

Other tags:
    Since: - v3.1.0

Returns:
  • (void) -

Parameters:
  • filter_class (Class) -- The class of the filter you want to delete
def delete_filter(filter_class)
  # rubocop:disable Style/ClassEqualityComparison
  index = @filters.index { |f| f.class.name == filter_class.name }
  # rubocop:enable Style/ClassEqualityComparison
  @filters.delete_at(index) if index
end

def filter_classes

def filter_classes
  @filters.map(&:class)
end

def includes?(filter_class)

Other tags:
    Since: - v4.14.0

Returns:
  • (Boolean) - true if the current chain has an instance of the given

Parameters:
  • filter_class (Class) --
def includes?(filter_class)
  filter_classes.include?(filter_class)
end

def initialize

def initialize
  @filters = []
end

def inspect

Returns:
  • (String) - customized inspect to lessen the amount of clutter
def inspect
  filter_classes.to_s
end

def pretty_print(q)

Returns:
  • (String) - {#inspect} for PrettyPrint
def pretty_print(q)
  q.text('[')
  # Make nesting of the first element consistent on JRuby and MRI.
  q.nest(2) { q.breakable } if @filters.any?
  q.nest(2) do
    q.seplist(@filters) { |f| q.pp(f.class) }
  end
  q.text(']')
end

def refine(notice)

Other tags:
    Todo: - Make it work with anything, not only notices

Returns:
  • (void) -

Parameters:
  • notice (Airbrake::Notice) -- The notice to be filtered
def refine(notice)
  @filters.each do |filter|
    break if notice.ignored?
    filter.call(notice)
  end
end