Class: AbideDevUtils::CEM::HieraData::ResourceData::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb

Instance Method Summary collapse

Constructor Details

#initialize(*param_collections) ⇒ Parameters

Returns a new instance of Parameters.



10
11
12
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb', line 10

def initialize(*param_collections)
  @param_collections = param_collections
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb', line 14

def exist?
  !@param_collections.nil? && !@param_collections.empty?
end

#to_display_fmtObject



31
32
33
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb', line 31

def to_display_fmt
  to_h[:parameters].values.map { |x| x[:display_value] }
end

#to_hObject



18
19
20
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb', line 18

def to_h
  @to_h ||= { parameters: @param_collections.map { |x| collection_to_h(x) unless x.nil? || x.empty? } }
end

#to_puppet_codeObject



22
23
24
25
26
27
28
29
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb', line 22

def to_puppet_code
  parray = to_h[:parameters].each_with_object([]) do |x, arr|
    x.each do |_, val|
      arr << param_to_code(**val[:display_value]) if val.respond_to?(:key)
    end
  end
  parray.reject { |x| x.nil? || x.empty? }.compact.join("\n")
end