Class: Puppet::Util::Hiera::ParentResource
- Inherits:
-
Object
- Object
- Puppet::Util::Hiera::ParentResource
- Defined in:
- lib/puppet/util/hiera/parent_resource.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #get_id ⇒ Object
- #get_parent_names ⇒ Object
-
#initialize(type, name, data, parent) ⇒ ParentResource
constructor
A new instance of ParentResource.
- #update_defaults(defaults, defaults_mapping) ⇒ Object
- #update_require(res_data) ⇒ Object
Constructor Details
#initialize(type, name, data, parent) ⇒ ParentResource
Returns a new instance of ParentResource.
8 9 10 11 12 13 14 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 8 def initialize(type, name, data, parent) @type = type @name = name data['title'] = name @data = data @parent = parent end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 5 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 4 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 6 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 3 def type @type end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 20 def [](key) @data[key] end |
#get_id ⇒ Object
16 17 18 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 16 def get_id() return "#{@type.capitalize}[#{@name}]" end |
#get_parent_names ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 24 def get_parent_names if @parent === nil return @name else return "#{@parent.get_parent_names}_#{@name}" end end |
#update_defaults(defaults, defaults_mapping) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 45 def update_defaults(defaults, defaults_mapping) defaults_mapping.each do | param, value | value = { value => nil } if not value.is_a?(Hash) value.each do | val, toreplaceval | if toreplaceval defaults[val] = toreplaceval.gsub(/([^&]?)&\{#{param}\}/, '\1' + @data[param]).gsub("&&", "&") else defaults[val] = @data[param] end end end end |
#update_require(res_data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet/util/hiera/parent_resource.rb', line 32 def update_require(res_data) if res_data['require'] if res_data['require'].is_a?(Array) res_data['require'] << get_id() else res_data['require'] = [ res_data['require'], get_id() ] end else res_data['require'] = [ get_id() ] end ModuleLoader.debug("rd-require: #{res_data['require'].inspect}") end |