Class: Puppet::Pops::Loaders::ModuleResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/loaders.rb

Overview

Resolves module loaders - resolution of model dependencies is done by Puppet::Module

Instance Method Summary collapse

Constructor Details

#initialize(loaders) ⇒ ModuleResolver

Returns a new instance of ModuleResolver.



359
360
361
362
363
# File 'lib/puppet/pops/loaders.rb', line 359

def initialize(loaders)
  @loaders = loaders
  @index = {}
  @all_module_loaders = nil
end

Instance Method Details

#[](name) ⇒ Object



365
366
367
# File 'lib/puppet/pops/loaders.rb', line 365

def [](name)
  @index[name]
end

#[]=(name, module_data) ⇒ Object



369
370
371
# File 'lib/puppet/pops/loaders.rb', line 369

def []=(name, module_data)
  @index[name] = module_data
end

#all_module_loadersObject



373
374
375
# File 'lib/puppet/pops/loaders.rb', line 373

def all_module_loaders
  @all_module_loaders ||= @index.values.map {|md| md.public_loader }
end

#resolve(module_data) ⇒ Object



377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/puppet/pops/loaders.rb', line 377

def resolve(module_data)
  if module_data.resolved?
    nil
  else
    module_data.private_loader =
      if module_data.restrict_to_dependencies?
        create_loader_with_only_dependencies_visible(module_data)
      else
        create_loader_with_all_modules_visible(module_data)
      end
  end
end