Class: StructUnpacker

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-common/v5/StructUnpacker.rb

Constant Summary collapse

SERIALIZE_HEADER =
"S"
JSON_HEADER =
"J"
MSG_HEADER =
"M"
RFC3986_HEADER =
"H"

Class Method Summary collapse

Class Method Details

.parse_payload(decrypted_payload) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby-common/v5/StructUnpacker.rb', line 14

def self.parse_payload(decrypted_payload)
  header = decrypted_payload.to_s[0]

  case header
  when SERIALIZE_HEADER, "Serialize", "serialize"
    return serialize_unpack(decrypted_payload)
  when MSG_HEADER, "Msgpack", "msgpack"
    return msg_unpack(decrypted_payload)
  when JSON_HEADER, "StructJson", "json"
    return json_unpack(decrypted_payload)
  when RFC3986_HEADER, "StructRfc3986", "rfc3986"
    return rfc3986_unpack(decrypted_payload)
  else
    raise StructParseError, "Unsupported struct class #{header}"
  end
end