Method: WCC::Filters.accept

Defined in:
lib/wcc/filter.rb

.accept(data, filters) ⇒ Boolean

Called by wcc check routine to evaluate all filters and produce and’ed result of their boolean returns.

Parameters:

  • data (Object)

    arbitrary data the filters might use

  • filters (Array)

    list of FilterRefs with the IDs of the filters to be executed

Returns:

  • (Boolean)

    true if all filters returned true, false otherwise



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/wcc/filter.rb', line 60

def self.accept(data, filters)
	return true if filters.nil?
	
	WCC.logger.info "Testing with filters: #{filters.join(', ')}"
	filters.each do |fref|
		block = @@filters[fref.id]
		if block.nil?
			WCC.logger.error "Requested filter '#{fref.id}' not found, skipping it."
			next
		end
		if not block.call(data, fref.arguments)
			WCC.logger.info "Filter '#{fref.id}' failed!"
			return false
		end
	end
	true
end