Module: CfnParser

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

Instance Method Summary collapse

Instance Method Details

#array(json) ⇒ Object



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

def array(json)
  return json.map { |a| parse_cfn_json(a) }
end

#hash(json) ⇒ Object



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

def hash(json)
  return json.merge(json) { |k, v| parse_cfn_json(v) }
end

#intrinsic_function(json) ⇒ Object



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

def intrinsic_function(json)
  fn_name    = json.keys.first
  values     = json[fn_name]
  parameters = parse_cfn_json(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_json(json) ⇒ Object



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

def parse_cfn_json(json)
  send(element_type(json).to_s.snake_case, json)
end

#primitive(json) ⇒ Object



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

def primitive(json)
  json
end