Class: Mccloud::Config::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/mccloud/config/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Template

Returns a new instance of Template.



12
13
14
15
# File 'lib/mccloud/config/template.rb', line 12

def initialize(config)
  @env=config.env
  @components=Hash.new
end

Instance Attribute Details

#componentsObject

Returns the value of attribute components.



9
10
11
# File 'lib/mccloud/config/template.rb', line 9

def components
  @components
end

#envObject (readonly)

Returns the value of attribute env.



10
11
12
# File 'lib/mccloud/config/template.rb', line 10

def env
  @env
end

Instance Method Details

#define(name) {|template_stub| ... } ⇒ Object

Yields:

  • (template_stub)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mccloud/config/template.rb', line 17

def define(name)
  # We do this for vagrant syntax
  # Depending on type, we create a variable of that type
  # f.i. component_stub.vm or component_stub.lb
  template_stub=OpenStruct.new
  template_stub.template=::Mccloud::Template.new(name,env)

  env.logger.debug("config template"){ "Start reading template"}

  yield template_stub

  env.logger.debug("config template"){ "End reading template #{template_stub.template.name}"}

  components[name.to_s]=template_stub.template
end