Class: TTY::Config::Marshallers::YAMLMarshaller

Inherits:
Object
  • Object
show all
Includes:
TTY::Config::Marshaller
Defined in:
lib/tty/config/marshallers/yaml_marshaller.rb

Overview

Responsible for marshalling content from and into YAML format

Instance Method Summary collapse

Methods included from TTY::Config::Marshaller

included

Instance Method Details

#marshal(object) ⇒ Object



18
19
20
# File 'lib/tty/config/marshallers/yaml_marshaller.rb', line 18

def marshal(object)
  YAML.dump(TTY::Config.normalize_hash(object, :to_s))
end

#unmarshal(content) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/tty/config/marshallers/yaml_marshaller.rb', line 22

def unmarshal(content)
  if YAML.respond_to?(:safe_load)
    YAML.safe_load(content)
  else
    YAML.load(content)
  end
end