class Puppet::Pops::Loader::StaticLoader

Constants

BUILTIN_ALIASES
BUILTIN_TYPE_NAMES
BUILTIN_TYPE_NAMES_LC

Attributes

loaded[R]

Public Class Methods

new() click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
40 def initialize
41   @loaded = {}
42   @runtime_3_initialized = false
43   create_built_in_types
44 end

Public Instance Methods

discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY) { |tn| ... } click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
46 def discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY)
47   # Static loader only contains runtime types
48   return EMPTY_ARRAY unless type == :type && name_authority == name_authority = Pcore::RUNTIME_NAME_AUTHORITY #rubocop:disable Lint/AssignmentInCondition
49 
50   typed_names = type == :type && name_authority == Pcore::RUNTIME_NAME_AUTHORITY ? @loaded.keys : EMPTY_ARRAY
51   block_given? ? typed_names.select { |tn| yield(tn) } : typed_names
52 end
find(name) click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
66 def find(name)
67   # There is nothing to search for, everything this loader knows about is already available
68   nil
69 end
get_entry(typed_name) click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
58 def get_entry(typed_name)
59   load_constant(typed_name)
60 end
load_typed(typed_name) click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
54 def load_typed(typed_name)
55   load_constant(typed_name)
56 end
loaded_entry(typed_name, check_dependencies = false) click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
79 def loaded_entry(typed_name, check_dependencies = false)
80   @loaded[typed_name]
81 end
parent() click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
71 def parent
72   nil # at top of the hierarchy
73 end
register_aliases() click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
91 def register_aliases
92   aliases = BUILTIN_ALIASES.map { |name, string| add_type(name, Types::PTypeAliasType.new(name, Types::TypeFactory.type_reference(string), nil)) }
93   aliases.each { |type| type.resolve(self) }
94 end
runtime_3_init() click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
83 def runtime_3_init
84   unless @runtime_3_initialized
85     @runtime_3_initialized = true
86     create_resource_type_references
87   end
88   nil
89 end
set_entry(typed_name, value, origin = nil) click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
62 def set_entry(typed_name, value, origin = nil)
63   @loaded[typed_name] = Loader::NamedEntry.new(typed_name, value, origin)
64 end
to_s() click to toggle source
   # File lib/puppet/pops/loader/static_loader.rb
75 def to_s()
76   "(StaticLoader)"
77 end

Private Instance Methods

add_type(name, type) click to toggle source
    # File lib/puppet/pops/loader/static_loader.rb
118 def add_type(name, type)
119   set_entry(TypedName.new(:type, name), type)
120   type
121 end
create_built_in_types() click to toggle source
    # File lib/puppet/pops/loader/static_loader.rb
102 def create_built_in_types
103   origin_uri = URI("puppet:Puppet-Type-System/Static-Loader")
104   type_map = Puppet::Pops::Types::TypeParser.type_map
105   type_map.each do |name, type|
106     set_entry(TypedName.new(:type, name), type, origin_uri)
107   end
108 end
create_resource_type_reference(name) click to toggle source
    # File lib/puppet/pops/loader/static_loader.rb
123 def create_resource_type_reference(name)
124   add_type(name, Types::TypeFactory.resource(name))
125 end
create_resource_type_references() click to toggle source
    # File lib/puppet/pops/loader/static_loader.rb
110 def create_resource_type_references()
111   # These needs to be done quickly and we do not want to scan the file system for these
112   # We are also not interested in their definition only that they exist.
113   # These types are in all environments.
114   #
115   BUILTIN_TYPE_NAMES.each { |name| create_resource_type_reference(name) }
116 end
load_constant(typed_name) click to toggle source
    # File lib/puppet/pops/loader/static_loader.rb
 98 def load_constant(typed_name)
 99   @loaded[typed_name]
100 end
synchronize() { || ... } click to toggle source
    # File lib/puppet/pops/loader/static_loader.rb
127 def synchronize(&block)
128   yield
129 end