1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
module RSpec::Puppet
if defined?(::Puppet::Pops::Types::PSensitiveType::Sensitive)
# A wrapper representing Sensitive data type, eg. in class params.
class Sensitive < ::Puppet::Pops::Types::PSensitiveType::Sensitive
# Create a new Sensitive object
# @param [Object] value to wrap
def initialize(value)
@value = value
end
# @return the wrapped value
def unwrap
@value
end
# @return true
def sensitive?
true
end
# @return inspect of the wrapped value, inside Sensitive()
def inspect
"Sensitive(#{@value.inspect})"
end
# Check for equality with another value.
# If compared to Puppet Sensitive type, it compares the wrapped values.
# @param other [#unwrap, Object] value to compare to
def == other
if other.respond_to? :unwrap
if unwrap.kind_of?(Regexp)
return unwrap =~ other.unwrap
else
return unwrap == other.unwrap
end
else
super
end
end
end
else
#:nocov:
class Sensitive
def initialize(value)
raise 'The use of the Sensitive data type is not supported by this Puppet version'
end
end
#:nocov:
end
end
|