Class: Lono::Template::Strategy::Dsl::Builder::Section::Resource::PropertyMover
- Inherits:
-
Object
- Object
- Lono::Template::Strategy::Dsl::Builder::Section::Resource::PropertyMover
- Defined in:
- lib/lono/template/strategy/dsl/builder/section/resource/property_mover.rb
Overview
Moves the property to the top-level attributes destructively
Instance Method Summary collapse
-
#initialize(resource, logical_id, properties) ⇒ PropertyMover
constructor
A new instance of PropertyMover.
- #move(attribute_name) ⇒ Object
- #move! ⇒ Object
Constructor Details
#initialize(resource, logical_id, properties) ⇒ PropertyMover
Returns a new instance of PropertyMover.
4 5 6 |
# File 'lib/lono/template/strategy/dsl/builder/section/resource/property_mover.rb', line 4 def initialize(resource, logical_id, properties) @resource, @logical_id, @properties = resource, logical_id, properties end |
Instance Method Details
#move(attribute_name) ⇒ Object
18 19 20 21 |
# File 'lib/lono/template/strategy/dsl/builder/section/resource/property_mover.rb', line 18 def move(attribute_name) attribute_value = @properties.delete(attribute_name) @resource[@logical_id][attribute_name] = attribute_value if attribute_value end |
#move! ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/lono/template/strategy/dsl/builder/section/resource/property_mover.rb', line 8 def move! %w[Condition DeletionPolicy DependsOn].each do |attribute_name| # Account for camelize, underscore, String, and Symbol move(attribute_name.to_sym) move(attribute_name.camelize.to_sym) move(attribute_name) move(attribute_name.camelize) end end |