Method: Puppet::Pops::Types::PSensitiveType.new_function

Defined in:
lib/puppet/pops/types/p_sensitive_type.rb

.new_function(type) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/puppet/pops/types/p_sensitive_type.rb', line 51

def self.new_function(type)
  @new_function ||= Puppet::Functions.create_loaded_function(:new_Sensitive, type.loader) do

    dispatch :from_sensitive do
      param 'Sensitive', :value
    end

    dispatch :from_any do
      param 'Any', :value
    end

    def from_any(value)
      Sensitive.new(value)
    end

    # Since the Sensitive value is immutable we can reuse the existing instance instead of making a copy.
    def from_sensitive(value)
      value
    end
  end
end