lib/sensu/server/filter.rb
def event_filtered?(handler, event)
        if handler.has_key?(:filters) || handler.has_key?(:filter)
          filter_list = Array(handler[:filters] || handler[:filter]).dup
          filter = Proc.new do |filter_list|
            filter_name = filter_list.shift
            if filter_name.nil?
              yield(false)
            else
              event_filter(filter_name, event) do |filtered|
                filtered ? yield(true, filter_name) : EM.next_tick { filter.call(filter_list) }
              end
            end
          end
          filter.call(filter_list)
        else
          yield(false)
        end
      end
# Determine if an event is filtered for a handler. If a handler
# specifies one or more filters, via `:filters` or `:filter`,
# the `event_filter()` method is called for each of them. If any
# of the filters return `true`, the event is filtered for the
# handler. If no filters are defined in the handler definition,
# the event is not filtered.
#
# @param handler [Hash] definition.
# @param event [Hash]
# @yield [filtered] callback/block called with a single
#   parameter to indicate if the event was filtered.
# @yieldparam filtered [TrueClass,FalseClass] indicating if the
#   event was filtered.
Determine if an event is filtered for a handler.
Determine if an event is filtered for a handler .
def event_filtered?(handler, event)
        if handler.has_key?(:filters) || handler.has_key?(:filter)
          filter_list = Array(handler[:filters] || handler[:filter]).dup
          filter = Proc.new do |filter_list|
            filter_name = filter_list.shift
            if filter_name.nil?
              yield(false)
            else
              event_filter(filter_name, event) do |filtered|
                filtered ? yield(true, filter_name) : EM.next_tick { filter.call(filter_list) }
              end
            end
          end
          filter.call(filter_list)
        else
          yield(false)
        end
      end
def event_filtered? ( handler , event ) if handler . has_key? ( :filters ) || handler . has_key? ( :filter ) filter_list = Array ( handler [ :filters ] || handler [ :filter ] ) . dup filter = Proc . new do | filter_list | filter_name = filter_list . shift if filter_name . nil? yield ( false ) else event_filter ( filter_name , event ) do | filtered | filtered ? yield ( true , filter_name ) : EM . next_tick { filter . call ( filter_list ) } end end end filter . call ( filter_list ) else yield ( false ) end end
Determine if an event is filtered for a handler.
Determine if an event is filtered for a handler .
handler
None
event
None
]
callback/block called with a single parameter to indicate if the event was filtered.
callback / block called with a single parameter to indicate if the event was filtered .
filtered
indicating if the event was filtered.
indicating if the event was filtered .