Class: AwsProvisioner::Template
- Defined in:
- lib/aws_provisioner/template.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#format_version ⇒ Object
readonly
Returns the value of attribute format_version.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
- #add(resource) ⇒ Object
- #compile(format) ⇒ Object
-
#initialize(name = nil, description: nil) ⇒ Template
constructor
A new instance of Template.
- #to_h ⇒ Object
Constructor Details
#initialize(name = nil, description: nil) ⇒ Template
Returns a new instance of Template.
10 11 12 13 14 15 |
# File 'lib/aws_provisioner/template.rb', line 10 def initialize(name=nil, description: nil) @format_version = "2010-09-09" @description = description @resources = [] @name = name end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/aws_provisioner/template.rb', line 8 def description @description end |
#format_version ⇒ Object (readonly)
Returns the value of attribute format_version.
8 9 10 |
# File 'lib/aws_provisioner/template.rb', line 8 def format_version @format_version end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/aws_provisioner/template.rb', line 7 def name @name end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
8 9 10 |
# File 'lib/aws_provisioner/template.rb', line 8 def resources @resources end |
Instance Method Details
#add(resource) ⇒ Object
17 18 19 |
# File 'lib/aws_provisioner/template.rb', line 17 def add(resource) resources << resource end |
#compile(format) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/aws_provisioner/template.rb', line 29 def compile(format) case format when :json JSON.pretty_generate(to_h) when :yaml YAML.dump(to_h) end end |
#to_h ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/aws_provisioner/template.rb', line 21 def to_h { "AWSTemplateFormatVersion" => format_version, "Description" => description, "Resources" => resources_to_h, } end |