Class: Skywriter::Template
- Inherits:
-
Object
- Object
- Skywriter::Template
- Defined in:
- lib/skywriter/template.rb
Overview
CloudFormation Template
Represents a CloudFormation template.
Defined Under Namespace
Classes: MergeError
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#format_version ⇒ Object
readonly
Returns the value of attribute format_version.
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
-
#as_json ⇒ Hash
Returns a hash representing the Template.
-
#initialize(options = {}) ⇒ Template
constructor
Constructor.
- #merge(other) ⇒ Object
-
#to_json ⇒ String
Returns a JSON string representing the Template.
Constructor Details
#initialize(options = {}) ⇒ Template
Constructor
See the AWS Documentation for details on the meaning of these parameters: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/concept-template.html
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/skywriter/template.rb', line 39 def initialize( = {}) @format_version = ([:format_version] || '2010-09-09').freeze @description = [:description].freeze @parameters = (access_liberally(, :parameters) || {}).freeze @mappings = (access_liberally(, :mappings) || {}).freeze @conditions = (access_liberally(, :conditions) || {}).freeze @resources = resources_as_json(access_liberally(, :resources)).freeze @outputs = (access_liberally(, :outputs) || {}).freeze end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
23 24 25 |
# File 'lib/skywriter/template.rb', line 23 def conditions @conditions end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
22 23 24 |
# File 'lib/skywriter/template.rb', line 22 def description @description end |
#format_version ⇒ Object (readonly)
Returns the value of attribute format_version.
22 23 24 |
# File 'lib/skywriter/template.rb', line 22 def format_version @format_version end |
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
23 24 25 |
# File 'lib/skywriter/template.rb', line 23 def mappings @mappings end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
23 24 25 |
# File 'lib/skywriter/template.rb', line 23 def outputs @outputs end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
23 24 25 |
# File 'lib/skywriter/template.rb', line 23 def parameters @parameters end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
23 24 25 |
# File 'lib/skywriter/template.rb', line 23 def resources @resources end |
Instance Method Details
#as_json ⇒ Hash
Returns a hash representing the Template
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/skywriter/template.rb', line 62 def as_json(*) { 'FormatVersion' => format_version, 'Description' => description, 'Parameters' => parameters, 'Mappings' => mappings, 'Conditions' => conditions, 'Resources' => resources, 'Outputs' => outputs, }.reject { |key, value| value.nil? } end |
#merge(other) ⇒ Object
74 75 76 |
# File 'lib/skywriter/template.rb', line 74 def merge(other) dup.merge!(other) end |
#to_json ⇒ String
Returns a JSON string representing the Template
54 55 56 |
# File 'lib/skywriter/template.rb', line 54 def to_json(*) JSON.pretty_generate(as_json) end |