Class: Humidifier::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/serializer.rb

Overview

Dumps an object to CFN syntax

Class Method Summary collapse

Class Method Details

.dump(node) ⇒ Object

dumps the given object out to CFN syntax recursively



8
9
10
11
12
13
14
15
16
17
# File 'lib/humidifier/serializer.rb', line 8

def dump(node)
  case node
  when Hash    then node.to_h { |key, value| [key, dump(value)] }
  when Array   then node.map { |value| dump(value) }
  when Ref, Fn then dump(node.to_cf)
  when Date    then node.iso8601
  when Time    then node.to_datetime.iso8601
  else node
  end
end