Class: Puppet::Pops::Loader::NullLoader

Inherits:
Loader show all
Defined in:
lib/puppet/pops/loader/null_loader.rb

Overview

The null loader is empty and delegates everything to its parent if it has one.

Constant Summary

Constants inherited from Loader

Loader::LOADABLE_KINDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Loader

#[], #inspect, #load, #loadables, #private_loader

Constructor Details

#initialize(parent_loader = nil, loader_name = "null-loader") ⇒ NullLoader

Construct a NullLoader, optionally with a parent loader



8
9
10
11
# File 'lib/puppet/pops/loader/null_loader.rb', line 8

def initialize(parent_loader=nil, loader_name = "null-loader")
  super(loader_name)
  @parent = parent_loader
end

Instance Attribute Details

#loader_nameObject (readonly)



4
5
6
# File 'lib/puppet/pops/loader/null_loader.rb', line 4

def loader_name
  @loader_name
end

Instance Method Details

#find(name) ⇒ Object

Finds nothing, there are no entries



48
49
50
51
52
53
54
# File 'lib/puppet/pops/loader/null_loader.rb', line 48

def find(typed_name)
  if @parent.nil?
    nil
  else
    @parent.find(typed_name)
  end
end

#get_entry(typed_name) ⇒ Object

Has no entries on its own - always nil



43
44
45
# File 'lib/puppet/pops/loader/null_loader.rb', line 43

def get_entry(typed_name)
  nil
end

#load_typed(typed_name) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/puppet/pops/loader/null_loader.rb', line 26

def load_typed(typed_name)
  if @parent.nil?
    nil
  else
    @parent.load_typed(typed_name)
  end
end

#loaded_entry(typed_name, check_dependencies = false) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/puppet/pops/loader/null_loader.rb', line 34

def loaded_entry(typed_name, check_dependencies = false)
  if @parent.nil?
    nil
  else
    @parent.loaded_entry(typed_name, check_dependencies)
  end
end

#parentObject

Has parent if one was set when constructed



14
15
16
# File 'lib/puppet/pops/loader/null_loader.rb', line 14

def parent
  @parent
end

#set_entry(typed_name, value, origin = nil) ⇒ Object

Cannot store anything



53
54
55
# File 'lib/puppet/pops/loader/null_loader.rb', line 53

def set_entry(typed_name, value, origin = nil)
  nil
end

#to_sObject



57
58
59
# File 'lib/puppet/pops/loader/null_loader.rb', line 57

def to_s()
  "(NullLoader '#{loader_name}')"
end