Method: Facter::Util::Fact#value

Defined in:
lib/facter/custom_facts/util/fact.rb

#valueObject

Returns the value for this fact. This searches all resolutions by suitability and weight (see Resolution). If no suitable resolution is found, it returns nil.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/facter/custom_facts/util/fact.rb', line 121

def value
  return @value unless @value.nil?

  if @resolves.empty?
    log.debug format('No resolves for %<name>s', name: @name)
    return nil
  end

  searching do
    suitable_resolutions = sort_by_weight(find_suitable_resolutions(@resolves))

    Facter::Framework::Benchmarking::Timer.measure(@name) do
      @value = find_first_real_value(suitable_resolutions)
    end

    announce_when_no_suitable_resolution(suitable_resolutions)
    announce_when_no_value_found(@value)

    @value = resolve_value
  end

  @value
end