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

Private Instance Methods

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