Class: Puppet::Pops::Types::PSensitiveType
- Inherits:
-
PTypeWithContainedType
- Object
- TypedModelObject
- PAnyType
- PTypeWithContainedType
- Puppet::Pops::Types::PSensitiveType
- Defined in:
- lib/puppet/pops/types/p_sensitive_type.rb
Defined Under Namespace
Classes: Sensitive
Instance Attribute Summary
Attributes inherited from PTypeWithContainedType
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type = nil) ⇒ PSensitiveType
constructor
A new instance of PSensitiveType.
- #instance?(o, guard = nil) ⇒ Boolean
Methods inherited from PTypeWithContainedType
#accept, #eql?, #generalize, #hash, #normalize, #resolve
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #eql?, #generalize, #hash, #iterable?, #iterable_type, #kind_of_callable?, #loader, #name, #new_function, #normalize, #really_instance?, #resolve, #roundtrip_with_string?, #simple_name, simple_name, #to_alias_expanded_s, #to_s
Methods inherited from TypedModelObject
_pcore_type, create_ptype, register_ptypes
Methods included from Visitable
Methods included from PuppetObject
#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s
Constructor Details
#initialize(type = nil) ⇒ PSensitiveType
Returns a new instance of PSensitiveType.
43 44 45 |
# File 'lib/puppet/pops/types/p_sensitive_type.rb', line 43 def initialize(type = nil) @type = type.nil? ? PAnyType.new : type.generalize end |
Class Method Details
.new_function(type) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# 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 |
.register_ptype(loader, ir) ⇒ Object
39 40 41 |
# File 'lib/puppet/pops/types/p_sensitive_type.rb', line 39 def self.register_ptype(loader, ir) create_ptype(loader, ir, 'AnyType') end |
Instance Method Details
#instance?(o, guard = nil) ⇒ Boolean
47 48 49 |
# File 'lib/puppet/pops/types/p_sensitive_type.rb', line 47 def instance?(o, guard = nil) o.is_a?(Sensitive) && @type.instance?(o.unwrap, guard) end |