class Puppet::Pops::Types::PSensitiveType

A Puppet Language type that wraps sensitive information. The sensitive type is parameterized by the wrapped value type.

@api public

Constants

DEFAULT

Public Class Methods

new(type = nil) click to toggle source
   # File lib/puppet/pops/types/p_sensitive_type.rb
43 def initialize(type = nil)
44   @type = type.nil? ? PAnyType.new : type.generalize
45 end
new_function(type) click to toggle source
   # File lib/puppet/pops/types/p_sensitive_type.rb
51 def self.new_function(type)
52   @new_function ||= Puppet::Functions.create_loaded_function(:new_Sensitive, type.loader) do
53 
54     dispatch :from_sensitive do
55       param 'Sensitive', :value
56     end
57 
58     dispatch :from_any do
59       param 'Any', :value
60     end
61 
62     def from_any(value)
63       Sensitive.new(value)
64     end
65 
66     # Since the Sensitive value is immutable we can reuse the existing instance instead of making a copy.
67     def from_sensitive(value)
68       value
69     end
70   end
71 end
register_ptype(loader, ir) click to toggle source
   # File lib/puppet/pops/types/p_sensitive_type.rb
39 def self.register_ptype(loader, ir)
40   create_ptype(loader, ir, 'AnyType')
41 end

Public Instance Methods

from_any(value) click to toggle source
   # File lib/puppet/pops/types/p_sensitive_type.rb
62 def from_any(value)
63   Sensitive.new(value)
64 end
from_sensitive(value) click to toggle source

Since the Sensitive value is immutable we can reuse the existing instance instead of making a copy.

   # File lib/puppet/pops/types/p_sensitive_type.rb
67 def from_sensitive(value)
68   value
69 end
instance?(o, guard = nil) click to toggle source
   # File lib/puppet/pops/types/p_sensitive_type.rb
47 def instance?(o, guard = nil)
48   o.is_a?(Sensitive) && @type.instance?(o.unwrap, guard)
49 end

Private Instance Methods

_assignable?(o, guard) click to toggle source
   # File lib/puppet/pops/types/p_sensitive_type.rb
75 def _assignable?(o, guard)
76   self.class == o.class && @type.assignable?(o.type, guard)
77 end