Class: Moonshot::DynamicTemplate
- Inherits:
-
Object
- Object
- Moonshot::DynamicTemplate
- Defined in:
- lib/moonshot/dynamic_template.rb
Defined Under Namespace
Classes: Parameters
Instance Attribute Summary collapse
-
#destination ⇒ Object
writeonly
Sets the attribute destination.
Instance Method Summary collapse
-
#initialize(source:, parameters:, destination:) ⇒ DynamicTemplate
constructor
A new instance of DynamicTemplate.
- #parameters_file ⇒ Object
- #parameters_obj ⇒ Object
- #process ⇒ Object
Constructor Details
#initialize(source:, parameters:, destination:) ⇒ DynamicTemplate
Returns a new instance of DynamicTemplate.
29 30 31 32 33 |
# File 'lib/moonshot/dynamic_template.rb', line 29 def initialize(source:, parameters:, destination:) @source = File.read(source) @parameters = parameters @destination = destination end |
Instance Attribute Details
#destination=(value) ⇒ Object (writeonly)
Sets the attribute destination
27 28 29 |
# File 'lib/moonshot/dynamic_template.rb', line 27 def destination=(value) @destination = value end |
Instance Method Details
#parameters_file ⇒ Object
39 40 41 42 |
# File 'lib/moonshot/dynamic_template.rb', line 39 def parameters_file env_name = Moonshot.config.environment_name @parameters.respond_to?(:call) ? @parameters.call(env_name) : @parameters end |
#parameters_obj ⇒ Object
35 36 37 |
# File 'lib/moonshot/dynamic_template.rb', line 35 def parameters_obj @parameters_obj ||= Parameters.new(parameters_file) end |
#process ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/moonshot/dynamic_template.rb', line 44 def process validate_destination_exists new_template = generate_template validate_template(new_template) write_output(new_template) end |