Method: Sfn::CommandModule::Stack::InstanceMethods#prefix_parameters_setup

Defined in:
lib/sfn/command_module/stack.rb

#prefix_parameters_setup(sparkle) ⇒ Array<Array<String>, Smash>

Generate name prefix for config parameter based on location and extract template parameters

Parameters:

  • sparkle (SparkleFormation, Hash)

    template instance

Returns:

  • (Array<Array<String>, Smash>)

    prefix value, parameters



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/sfn/command_module/stack.rb', line 111

def prefix_parameters_setup(sparkle)
  case sparkle
  when SparkleFormation
    parameter_prefix = sparkle.root? ? [] : (sparkle.root_path - [sparkle.root]).map do |s|
      Bogo::Utility.camel(s.name)
    end
    stack_parameters = sparkle.compile.parameters
    stack_parameters = stack_parameters.nil? ? Smash.new : stack_parameters._dump
  when Hash
    parameter_prefix = []
    stack_parameters = TEMPLATE_PARAMETER_LOCATIONS.map do |loc_key|
      sparkle[loc_key]
    end.compact.first || Smash.new
  else
    parameter_prefix = []
    stack_parameters = Smash.new
  end
  [parameter_prefix, stack_parameters]
end