On Mon, Jul 16, 2012 at 10:56 AM, Nan Liu <n...@puppetlabs.com> wrote:
> > > empty() should be an rvalue function. In this case posting the empty() > function would be more helpful than the puppet manifests. > > Nan > > It's the standard one shipped with stdlib: modules/stdlib/lib/puppet/parser/functions/empty.rb # # empty.rb # module Puppet::Parser::Functions newfunction(:empty, :type => :rvalue, :doc => <<-EOS Returns true if the variable is empty. EOS ) do |arguments| raise(Puppet::ParseError, "empty(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] klass = value.class unless [Array, Hash, String].include?(klass) raise(Puppet::ParseError, 'empty(): Requires either ' + 'array, hash or string to work with') end result = value.empty? return result end end # vim: set ts=2 sw=2 et : --dlloyd -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.