Class: Cfhighlander::Dsl::DslBase

Inherits:
Object
  • Object
show all
Defined in:
lib/cfhighlander.dsl.base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ DslBase

Returns a new instance of DslBase.



53
54
55
# File 'lib/cfhighlander.dsl.base.rb', line 53

def initialize (parent)
  @config = parent.config unless parent.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Raises:

  • (StandardError)


57
58
59
60
61
62
63
# File 'lib/cfhighlander.dsl.base.rb', line 57

def method_missing(method, *args)
  if @config.nil?
    raise StandardError, "#{self} no config!"
  end
  # return @config["#{method}"] unless @config["#{method}"].nil?
  raise StandardError, "#{self} Unknown method or variable #{method} in Cfhighlander template"
end

Instance Attribute Details

#config ⇒ Object

Returns the value of attribute config.



6
7
8
# File 'lib/cfhighlander.dsl.base.rb', line 6

def config
  @config
end

Instance Method Details

#cfmap(map, key, attr) ⇒ Object



48
49
50
# File 'lib/cfhighlander.dsl.base.rb', line 48

def cfmap(map, key, attr)
  return FindInMap(map, key, attr)
end

#cfout(resource, output = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cfhighlander.dsl.base.rb', line 33

def cfout(resource, output = nil)
  if output.nil?
    parts = resource.split('.')
    if parts.size() != 2
      raise "cfout('#{resource}'): If cfout given single argument cfout('component.OutputName') syntax must be used"
    else
      resource = parts[0]
      output = parts[1]
    end
  end

  return GetAtt(resource, "Outputs.#{output}")
end

#FindInMap(map, key, attr) ⇒ Object



29
30
31
# File 'lib/cfhighlander.dsl.base.rb', line 29

def FindInMap(map, key, attr)
  return FnFindInMap(map, key, attr)
end

#FnFindInMap(map, key, attr) ⇒ Object



25
26
27
# File 'lib/cfhighlander.dsl.base.rb', line 25

def FnFindInMap(map, key, attr)
  return { 'Fn::FindInMap' => [map, key, attr] }
end

#FnGetAtt(resource, property) ⇒ Object



13
14
15
16
17
# File 'lib/cfhighlander.dsl.base.rb', line 13

def FnGetAtt(resource, property)
  return {
      'Fn::GetAtt' => [resource, property]
  }
end

#GetAtt(resource, property) ⇒ Object



9
10
11
# File 'lib/cfhighlander.dsl.base.rb', line 9

def GetAtt(resource, property)
  return FnGetAtt(resource, property)
end

#Ref(resource) ⇒ Object



19
20
21
22
23
# File 'lib/cfhighlander.dsl.base.rb', line 19

def Ref(resource)
  return {
      'Ref' => resource
  }
end