class Mmtrix::Agent::AttributeFilterRule
Attributes
attribute_name[R]
destinations[R]
is_include[R]
wildcard[R]
Public Class Methods
new(attribute_name, destinations, is_include)
click to toggle source
# File lib/mmtrix/agent/attribute_filter.rb, line 199 def initialize(attribute_name, destinations, is_include) @attribute_name = attribute_name.sub(/\*$/, "") @wildcard = attribute_name.end_with?("*") @is_include = is_include @destinations = is_include ? destinations : ~destinations end
Public Instance Methods
<=>(other)
click to toggle source
Rules are sorted from least specific to most specific
All else being the same, wildcards are considered less specific All else being the same, include rules are less specific than excludes
# File lib/mmtrix/agent/attribute_filter.rb, line 210 def <=>(other) name_cmp = @attribute_name <=> other.attribute_name return name_cmp unless name_cmp == 0 if wildcard != other.wildcard return wildcard ? -1 : 1 end if is_include != other.is_include return is_include ? -1 : 1 end return 0 end
empty?()
click to toggle source
# File lib/mmtrix/agent/attribute_filter.rb, line 233 def empty? if is_include @destinations == AttributeFilter::DST_NONE else @destinations == AttributeFilter::DST_ALL end end
match?(name)
click to toggle source
# File lib/mmtrix/agent/attribute_filter.rb, line 225 def match?(name) if wildcard name.start_with?(@attribute_name) else @attribute_name == name end end