Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / empty.rb
1 #
2 # empty.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:empty, :type => :rvalue, :doc => <<-DOC
6     Returns true if the variable is empty.
7
8     Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
9     will be used instead of this function.
10   DOC
11              ) do |arguments|
12
13     raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
14     value = arguments[0]
15
16     unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String) || value.is_a?(Numeric)
17       raise(Puppet::ParseError, 'empty(): Requires either array, hash, string or integer to work with')
18     end
19
20     return false if value.is_a?(Numeric)
21     result = value.empty?
22     return result
23   end
24 end
25
26 # vim: set ts=2 sw=2 et :