Module: MarilynRPC::MailFactory
- Includes:
- MailHelper
- Defined in:
- lib/marilyn-rpc/mails.rb
Overview
Helper to destiguish between the different mails
Constant Summary collapse
- TYPE_LOOK_UP =
table which contains all types that can be unpacked
{ MarilynRPC::CallRequestMail::TYPE => MarilynRPC::CallRequestMail, MarilynRPC::CallResponseMail::TYPE => MarilynRPC::CallResponseMail, MarilynRPC::ExceptionMail::TYPE => MarilynRPC::ExceptionMail }
Constants included from MailHelper
MarilynRPC::MailHelper::SERIALIZER
Class Method Summary collapse
-
.build_call(tag, path, method, args) ⇒ Object
builds the binary data for a method call, it inlines some of the packing for performance critical applications.
-
.unpack(envelope) ⇒ MarilynRPC::CallRequestMail, ...
Parses the envelop and generate the correct mail.
Class Method Details
.build_call(tag, path, method, args) ⇒ Object
builds the binary data for a method call, it inlines some of the packing for performance critical applications.
79 80 81 82 83 84 |
# File 'lib/marilyn-rpc/mails.rb', line 79 def self.build_call(tag, path, method, args) data = MarilynRPC::MailHelper::SERIALIZER.dump([tag, path, method, args]) [ data.size, MarilynRPC::CallRequestMail::TYPE ].pack(MarilynRPC::Envelope::HEADER_ENCODING) + data end |
.unpack(envelope) ⇒ MarilynRPC::CallRequestMail, ...
Parses the envelop and generate the correct mail.
61 62 63 64 65 66 67 68 |
# File 'lib/marilyn-rpc/mails.rb', line 61 def self.unpack(envelope) if mail_klass = TYPE_LOOK_UP[envelope.type] mail = mail_klass.new(*SERIALIZER.load(envelope.content)) else raise MarilynRPC::BrokenEnvelopeError.new \ "The passed envelope is broken, no (correct) type!" end end |