Class: ASIR::Coder::Yaml

Inherits:
ASIR::Coder show all
Defined in:
lib/asir/coder/yaml.rb

Overview

!SLIDE YAML Coder Use YAML for encode/decode.

Instance Attribute Summary collapse

Attributes included from Log

#_logger

Instance Method Summary collapse

Methods inherited from ASIR::Coder

#_subclass_responsibility, #decode, #encode, #prepare

Methods included from Log

#_log, #_log_enabled=, #_log_enabled?, #_log_format, #_log_result, enabled, enabled=, included

Methods included from Initialization

#initialize

Instance Attribute Details

#yaml_optionsObject

Returns the value of attribute yaml_options.



26
27
28
# File 'lib/asir/coder/yaml.rb', line 26

def yaml_options
  @yaml_options
end

Instance Method Details

#_decode(obj) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/asir/coder/yaml.rb', line 17

def _decode obj
  case obj = ::YAML::load(obj)
  when Message, Result
    obj.decode_more!
  else
    obj
  end
end

#_encode(obj) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/asir/coder/yaml.rb', line 9

def _encode obj
  case obj
  when Message, Result
    obj = obj.encode_more!
  end
  yaml_dump(obj)
end