Class: StackMaster::SparkleFormation::TemplateContext

Inherits:
AttributeStruct
  • Object
show all
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

Constructor Details

#initialize(vars, prefix) ⇒ TemplateContext

Returns a new instance of TemplateContext.



37
38
39
40
41
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 37

def initialize(vars, prefix)
  self._camel_keys = true
  @vars = vars
  @prefix = prefix
end

Class Method Details

.build(vars, prefix) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 26

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

Returns:

  • (Boolean)


43
44
45
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 43

def has_var?(var_key)
  @vars.include?(var_key)
end

#render(file_name, vars = {}) ⇒ Object



47
48
49
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 47

def render(file_name, vars = {})
  Template.render(@prefix, file_name, vars)
end