Class: MkStack::Section
- Inherits:
-
Object
- Object
- MkStack::Section
- Defined in:
- lib/mkstack/section.rb
Overview
A CloudFormation template section
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#exceeds_limit? ⇒ Boolean
Check if the section exceeds the AWS limit.
-
#initialize(name, type, limit = nil) ⇒ Section
constructor
-
name: The section’s name (Resources, Outputs, etc.) * type: The section’s type (Hash or String) * limit: The AWS limit for this section, if any.
-
-
#length ⇒ Object
Return the length of the section’s contents.
-
#merge(contents) ⇒ Object
Merge or override a section snippet.
Constructor Details
#initialize(name, type, limit = nil) ⇒ Section
-
name: The section’s name (Resources, Outputs, etc.)
-
type: The section’s type (Hash or String)
-
limit: The AWS limit for this section, if any
11 12 13 14 15 16 |
# File 'lib/mkstack/section.rb', line 11 def initialize(name, type, limit = nil) @name = name @limit = limit @contents = type.new end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
6 7 8 |
# File 'lib/mkstack/section.rb', line 6 def contents @contents end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/mkstack/section.rb', line 5 def limit @limit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/mkstack/section.rb', line 5 def name @name end |
Instance Method Details
#exceeds_limit? ⇒ Boolean
Check if the section exceeds the AWS limit
30 |
# File 'lib/mkstack/section.rb', line 30 def exceeds_limit?; @limit && length > @limit; end |
#length ⇒ Object
Return the length of the section’s contents
27 |
# File 'lib/mkstack/section.rb', line 27 def length; @contents.length; end |
#merge(contents) ⇒ Object
Merge or override a section snippet
19 20 21 22 23 24 |
# File 'lib/mkstack/section.rb', line 19 def merge(contents) raise TypeError.new("#{contents.class} != #{@contents.class}") if contents.class != @contents.class return @contents.merge!(contents) if @contents.respond_to?(:merge!) @contents = contents end |