Puppet Function: wmflib::encode_www_form

Defined in:
modules/wmflib/lib/puppet/functions/wmflib/encode_www_form.rb
Function type:
Ruby 4.x API

Summary

Convert a hash or form parameters into a uri encoded string

Overview

wmflib::encode_www_form(Hash $object)Any

Examples:

wmflib::encode_www_form({"q" => "ruby", "lang" => "en"})
=> "q=ruby&lang=en"
wmflib::encode_www_form({"q" => ["ruby", "perl"], "lang" => "en"})
=> "q=ruby&q=perl&lang=en"

Parameters:

  • object (Hash)

    the dictionary to encode

Returns:

  • (Any)

    A form encode representation of the dictr

See Also:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'modules/wmflib/lib/puppet/functions/wmflib/encode_www_form.rb', line 14

Puppet::Functions.create_function(:'wmflib::encode_www_form') do
  # @param object the dictionary to encode
  # @return A form encode representation of the dictr
  dispatch :encode_www_form do
    param 'Hash', :object
  end

  # @param object
  #   The object to be converted
  #
  # @return [String]
  #   A form encode representation of the dictr
  def encode_www_form(object)
    URI.encode_www_form(object)
  end
end