Class: StackMaster::SparkleFormation::TemplateContext
- Inherits:
-
AttributeStruct
- Object
- AttributeStruct
- StackMaster::SparkleFormation::TemplateContext
- Includes:
- SparkleFormation::SparkleAttribute, SparkleFormation::SparkleAttribute::Aws, SparkleFormation::Utils::TypeCheckers
- Defined in:
- lib/stack_master/sparkle_formation/template_file.rb
Class Method Summary collapse
Instance Method Summary collapse
- #has_var?(var_key) ⇒ Boolean
-
#initialize(vars, prefix) ⇒ TemplateContext
constructor
A new instance of TemplateContext.
- #render(file_name, vars = {}) ⇒ Object
Constructor Details
#initialize(vars, prefix) ⇒ TemplateContext
Returns a new instance of TemplateContext.
23 24 25 26 27 |
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 23 def initialize(vars, prefix) self._camel_keys = true @vars = vars @prefix = prefix end |
Class Method Details
.build(vars, prefix) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 13 def self.build(vars, prefix) ::Class.new(self).tap do |klass| vars.each do |key, value| klass.send(:define_method, key) do value end end end.new(vars, prefix) end |
Instance Method Details
#has_var?(var_key) ⇒ Boolean
29 30 31 |
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 29 def has_var?(var_key) @vars.include?(var_key) end |
#render(file_name, vars = {}) ⇒ Object
33 34 35 |
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 33 def render(file_name, vars = {}) Template.render(@prefix, file_name, vars) end |