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.



24
25
26
27
28
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 24

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
22
# 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

Returns:

  • (Boolean)


30
31
32
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 30

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

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



34
35
36
# File 'lib/stack_master/sparkle_formation/template_file.rb', line 34

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