From 799c38e14e1583e676e2b25a9c1782fd40e29fff Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 21 Sep 2015 10:56:08 -0700 Subject: Fix backwards compatibility from #511 Maintain the old behavior in the case where the optional second parameter isn't passed. Also, adding arity is backwards incompatible since stdlib still supports 2.7, so remove that. --- lib/puppet/parser/functions/parseyaml.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/puppet/parser/functions/parseyaml.rb') diff --git a/lib/puppet/parser/functions/parseyaml.rb b/lib/puppet/parser/functions/parseyaml.rb index d38b3ef..66d0413 100644 --- a/lib/puppet/parser/functions/parseyaml.rb +++ b/lib/puppet/parser/functions/parseyaml.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:parseyaml, :type => :rvalue, :arity => -2, :doc => <<-EOS + newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS This function accepts YAML as a string and converts it into the correct Puppet structure. @@ -16,8 +16,12 @@ be returned if the parsing of YAML string have failed. begin YAML::load(arguments[0]) || arguments[1] - rescue Exception - arguments[1] + rescue Exception => e + if arguments[1] + arguments[1] + else + raise e + end end end -- cgit v1.2.3