lib/custom_facts/util/fact.rb in facter-4.0.7.pre vs lib/custom_facts/util/fact.rb in facter-4.0.8.pre
- old
+ new
@@ -46,11 +46,11 @@
# block, which will then be evaluated in the context of the new
# resolution.
#
# @param options [Hash] A hash of options to set on the resolution
#
- # @return [LegacyFacter::Util::Resolution]
+ # @return [Facter::Util::Resolution]
#
# @api private
def add(options = {}, &block)
@options = options
define_resolution(nil, options, &block)
@@ -59,11 +59,11 @@
# Define a new named resolution or return an existing resolution with
# the given name.
#
# @param resolution_name [String] The name of the resolve to define or look up
# @param options [Hash] A hash of options to set on the resolution
- # @return [LegacyFacter::Util::Resolution]
+ # @return [Facter::Util::Resolution]
#
# @api public
def define_resolution(resolution_name, options = {}, &block)
resolution_type = options.delete(:type) || :simple
@@ -80,11 +80,11 @@
# Retrieve an existing resolution by name
#
# @param name [String]
#
- # @return [LegacyFacter::Util::Resolution, nil] The resolution if exists, nil if
+ # @return [Facter::Util::Resolution, nil] The resolution if exists, nil if
# it doesn't exist or name is nil
def resolution(name)
return nil if name.nil?
@resolves.find { |resolve| resolve.name == name }
@@ -161,21 +161,25 @@
resolutions.sort { |a, b| b.weight <=> a.weight }
end
def find_first_real_value(resolutions)
resolutions.each do |resolve|
- value = resolve.value
+ begin
+ value = resolve.value
+ rescue Facter::ResolveCustomFactError
+ break
+ end
@used_resolution_weight = resolve.weight
return value unless value.nil?
end
nil
end
def announce_when_no_suitable_resolution(resolutions)
return unless resolutions.empty?
- LegacyFacter.debug format('Found no suitable resolves of %<resolver_lengths for %<name>s',
+ LegacyFacter.debug format('Found no suitable resolves of %<resolver_length> for %<name>s',
resolver_length: @resolves.length, name: @name)
end
def announce_when_no_value_found(value)
LegacyFacter.debug(format('value for %<name>s is still nil', name: @name)) if value.nil?
@@ -190,10 +194,10 @@
" #{resolution_type}; already defined as #{resolve.resolution_type}"
end
else
case resolution_type
when :simple
- resolve = LegacyFacter::Util::Resolution.new(resolution_name, self)
+ resolve = Facter::Util::Resolution.new(resolution_name, self)
when :aggregate
resolve = LegacyFacter::Core::Aggregate.new(resolution_name, self)
else
raise ArgumentError,
"Expected resolution type to be one of (:simple, :aggregate) but was #{resolution_type}"