diff --git a/README.md b/README.md index 61c2405e7..b6d6c0dd2 100644 --- a/README.md +++ b/README.md @@ -1179,15 +1179,6 @@ For example, `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}. *Type*: rvalue. - -#### `ifelse` - -Shorthand version for if-else: this maps to the ruby tenary operator. - -For example, `ifelse(4 > 0, 'positive', 'negative')` returns `'positive'`. - -*Type*: rvalue. - #### `intersection` Returns an array an intersection of two. diff --git a/lib/puppet/functions/ifelse.rb b/lib/puppet/functions/ifelse.rb deleted file mode 100644 index a264c52d6..000000000 --- a/lib/puppet/functions/ifelse.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Shorthand for bool ? true value : false value. -# -# @example -# $number_sign = ifelse($i >= 0, "positive", "negative") -# -Puppet::Functions.create_function(:ifelse) do - # @param bool Boolean condition - # @param iftrue Value to return if condition is true. - # @param iffalse Value to return if condition is false. - # @return Value from `$iftrue` or `$iffalse` depending on the boolean condition. - dispatch :ifelse do - param 'Boolean', :bool - param 'Any', :iftrue - param 'Any', :iffalse - end - - def ifelse(bool, iftrue, iffalse) - bool ? iftrue : iffalse - end -end diff --git a/spec/functions/ifelse_spec.rb b/spec/functions/ifelse_spec.rb deleted file mode 100644 index 283fb3913..000000000 --- a/spec/functions/ifelse_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'ifelse' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects 3 arguments}i) } - it { is_expected.to run.with_params('1').and_raise_error(ArgumentError, %r{expects 3 arguments}i) } - - it { is_expected.to run.with_params('false', 'iftrue', 'iffalse').and_raise_error(ArgumentError, %r{parameter 'bool' expects a Boolean value}i) } - - it { is_expected.to run.with_params(false, 'iftrue', 'iffalse').and_return('iffalse') } - it { is_expected.to run.with_params(true, 'iftrue', 'iffalse').and_return('iftrue') } - it { is_expected.to run.with_params(true, :undef, 'iffalse').and_return(:undef) } - it { is_expected.to run.with_params(true, nil, 'iffalse').and_return(nil) } -end