Module: CfnParser

Included in:
Condition, Mapping, Metadata, Output, Resource, Rules
Defined in:
lib/cfn_parser.rb

Instance Method Summary collapse

Instance Method Details

#array(cfn_hash) ⇒ Object



13
14
15
# File 'lib/cfn_parser.rb', line 13

def array(cfn_hash)
  return cfn_hash.map { |a| parse_cfn(a) }
end

#hash(cfn_hash) ⇒ Object



24
25
26
# File 'lib/cfn_parser.rb', line 24

def hash(cfn_hash)
  return cfn_hash.merge(cfn_hash) { |k, v| parse_cfn(v) }
end

#intrinsic_function(cfn_hash) ⇒ Object



17
18
19
20
21
22
# File 'lib/cfn_parser.rb', line 17

def intrinsic_function(cfn_hash)
  fn_name    = cfn_hash.keys.first
  values     = cfn_hash[fn_name]
  parameters = parse_cfn(values)
  return IntrinsicFunction.new(fn_name, parameters)
end

#intrinsic_function?(obj) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/cfn_parser.rb', line 7

def intrinsic_function?(obj)
  obj.instance_of?(Hash) &&
  obj.keys.size == 1 &&
  (obj.keys.first =~ /^Fn::/ or obj.keys.first == "Ref")
end

#parse_cfn(cfn_hash) ⇒ Object



3
4
5
# File 'lib/cfn_parser.rb', line 3

def parse_cfn(cfn_hash)
  send(element_type(cfn_hash).to_s.snake_case, cfn_hash)
end

#primitive(cfn_hash) ⇒ Object



28
29
30
# File 'lib/cfn_parser.rb', line 28

def primitive(cfn_hash)
  cfn_hash
end