Class: Lono::Template::Strategy::Dsl::Finalizer::ParameterGroups
- Inherits:
-
Object
- Object
- Lono::Template::Strategy::Dsl::Finalizer::ParameterGroups
- Extended by:
- Memoist
- Includes:
- Builder::Stringify
- Defined in:
- lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb
Instance Method Summary collapse
-
#initialize(cfn, parameters) ⇒ ParameterGroups
constructor
A new instance of ParameterGroups.
- #interface ⇒ Object
- #parameter_groups ⇒ Object
- #parameter_labels ⇒ Object
- #run ⇒ Object
Methods included from Builder::Stringify
Constructor Details
#initialize(cfn, parameters) ⇒ ParameterGroups
Returns a new instance of ParameterGroups.
6 7 8 |
# File 'lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb', line 6 def initialize(cfn, parameters) @cfn, @parameters = cfn, parameters end |
Instance Method Details
#interface ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb', line 17 def interface interface = {} parameter_groups.each do |group_label, parameters| group = { Label: { default: group_label}, Parameters: parameters, } interface[:ParameterGroups] ||= [] interface[:ParameterGroups] << group end parameter_labels.each do |name, label| l = { name => { default: label } } interface[:ParameterLabels] ||= {} interface[:ParameterLabels].merge!(l) end interface end |
#parameter_groups ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb', line 35 def parameter_groups parameter_groups = {} @parameters.each do |p| next unless p.group_label parameter_groups[p.group_label] ||= [] parameter_groups[p.group_label] << p.name end parameter_groups end |
#parameter_labels ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb', line 46 def parameter_labels parameter_labels = {} @parameters.each do |p| next unless p.label parameter_labels[p.name] = p.label end parameter_labels end |
#run ⇒ Object
10 11 12 13 14 15 |
# File 'lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb', line 10 def run return @cfn if parameter_groups.empty? @cfn["Metadata"] ||= {} @cfn["Metadata"]["AWS::CloudFormation::Interface"] = stringify!(interface) @cfn end |