Module: MarilynRPC::MailHelper

Included in:
CallRequestMail, CallResponseMail, ExceptionMail
Defined in:
lib/marilyn-rpc/mails.rb

Overview

Helper that gets mixed into the mail classes to make common things easyer

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) type(nr)

generate a new serialize id which can be used in a mail

Parameters:

  • (Integer) a

    number between 0 and 254

  • (String) returns

    an 1 byte string as type id



7
8
9
# File 'lib/marilyn-rpc/mails.rb', line 7

def self.type(nr)
  [nr].pack("c")
end

Instance Method Details

- (Object) deserialize(data)

deserializes the passed data to the original objects

Parameters:

  • (String) data

    the serialized data

Returns:

  • (Object)

    the deserialized object



28
29
30
# File 'lib/marilyn-rpc/mails.rb', line 28

def deserialize(data)
  Marshal.load(data)
end

- (String) only_data(data)

extracts the real data and ignores the type information

Parameters:

  • (String) data

    the data to extract the mail from

Returns:

  • (String)

    the extracted data



14
15
16
# File 'lib/marilyn-rpc/mails.rb', line 14

def only_data(data)
  data.slice(1, data.size)
end

- (Object) serialize(data)

serialize the data using marilyns default serializer

Parameters:

  • (Object) data

    the data to encode

  • (String) the

    serialized data



21
22
23
# File 'lib/marilyn-rpc/mails.rb', line 21

def serialize(data)
  Marshal.dump(data)
end