Sha256: 54181f2c41b930f85315fde897c2392894cf88914c18b8e3172e9b1d0370b597
Contents?: true
Size: 1023 Bytes
Versions: 38
Compression:
Stored size: 1023 Bytes
Contents
# A restricting tag for fact resolution mechanisms. The tag must be true # for the resolution mechanism to be suitable. require 'facter/util/values' class Facter::Util::Confine attr_accessor :fact, :values include Facter::Util::Values # Add the restriction. Requires the fact name, an operator, and the value # we're comparing to. def initialize(fact, *values) raise ArgumentError, "The fact name must be provided" unless fact raise ArgumentError, "One or more values must be provided" if values.empty? @fact = fact @values = values end def to_s return "'%s' '%s'" % [@fact, @values.join(",")] end # Evaluate the fact, returning true or false. def true? unless fact = Facter[@fact] Facter.debug "No fact for %s" % @fact return false end value = convert(fact.value) return false if value.nil? @values.each do |v| v = convert(v) next unless v.class == value.class return true if value == v end return false end end
Version data entries
38 entries across 38 versions & 3 rubygems