Class: Stargate::Marshal::Payload

Inherits:
Struct
  • Object
show all
Includes:
Serialization
Defined in:
lib/stargate/marshal/payload.rb

Overview

Internal: We need some packaging to move stuff from one machine to another. We have to know what types are coming in. We distinguish four base types:

  • Simple type (string, number, booleans),

  • Symbol,

  • List (Array),

  • Hash

Later, we can pack any other type that has been registered for exchange.

Constant Summary collapse

LIST =
:a
SIMPLE =
:b
SYMBOL =
:s
HASH =
:h

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Serialization

#bencode, #to_json, #to_msgpack

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



14
15
16
# File 'lib/stargate/marshal/payload.rb', line 14

def data
  @data
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



14
15
16
# File 'lib/stargate/marshal/payload.rb', line 14

def type
  @type
end

Instance Method Details

#inspectObject



26
27
28
# File 'lib/stargate/marshal/payload.rb', line 26

def inspect
  serialize.inspect
end

#serializeObject



22
23
24
# File 'lib/stargate/marshal/payload.rb', line 22

def serialize
  [ type, data ]
end