Class: AbideDevUtils::CEM::HieraData::ResourceData::Parameters
- Inherits:
-
Object
- Object
- AbideDevUtils::CEM::HieraData::ResourceData::Parameters
- Defined in:
- lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(*param_collections) ⇒ Parameters
constructor
A new instance of Parameters.
- #to_display_fmt ⇒ Object
- #to_h ⇒ Object
- #to_puppet_code ⇒ Object
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
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_fmt ⇒ Object
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_h ⇒ Object
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_code ⇒ Object
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 |