403Webshell
Server IP : 104.21.14.103  /  Your IP : 18.223.106.79
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/lest.rb
# Calls a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
# without arguments if the value given to `lest` is `undef`.
# Returns the result of calling the lambda if the argument is `undef`, otherwise the
# given argument.
#
# The `lest` function is useful in a chain of `then` calls, or in general
# as a guard against `undef` values. The function can be used to call `fail`, or to
# return a default value.
#
# These two expressions are equivalent:
#
# ```puppet
# if $x == undef { do_things() }
# lest($x) || { do_things() }
# ```
#
# @example Using the `lest` function
#
# ```puppet
# $data = {a => [ b, c ] }
# notice $data.dig(a, b, c)
#  .then |$x| { $x * 2 }
#  .lest || { fail("no value for $data[a][b][c]" }
# ```
#
# Would fail the operation because `$data[a][b][c]` results in `undef`
# (there is no `b` key in `a`).
#
# In contrast - this example:
#
# ```puppet
# $data = {a => { b => { c => 10 } } }
# notice $data.dig(a, b, c)
#  .then |$x| { $x * 2 }
#  .lest || { fail("no value for $data[a][b][c]" }
# ```
#
# Would notice the value `20`
#
# @since 4.5.0
#
Puppet::Functions.create_function(:lest) do
  dispatch :lest do
    param 'Any', :arg
    block_param 'Callable[0,0]', :block
  end

  def lest(arg)
    if arg.nil?
      yield()
    else
      arg
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit