Class: Jets::Stack::Builder

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/stack/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(stack) ⇒ Builder

Returns a new instance of Builder.



5
6
7
8
# File 'lib/jets/stack/builder.rb', line 5

def initialize(stack)
  @stack = stack
  @template = {} # will build this structure up
end

Instance Method Details

#build_elements(section) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jets/stack/builder.rb', line 28

def build_elements(section)
  # s is a "section element".  Examples:
  #
  #   Jets::Stack::Parameter
  #   Jets::Stack::Resource
  #   Jets::Stack::Output
  #
  section_elements = @stack.send(section)
  return unless section_elements

  section_elements.inject({}) do |template_section, s|
    template_section.merge(s.template)
  end
end

#build_section(section) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/jets/stack/builder.rb', line 18

def build_section(section)
  elements = build_elements(section)
  return unless elements

  if section == :parameters
    elements["GemLayer"] = {"Type"=>"String"} unless Jets.poly_only?
  end
  @template[section] = elements
end

#templateObject



10
11
12
13
14
15
# File 'lib/jets/stack/builder.rb', line 10

def template
  build_section(:parameters)
  build_section(:resources)
  build_section(:outputs)
  Jets::Camelizer.transform(@template)
end