Class: RabbitRPC::Message
- Inherits:
-
Object
- Object
- RabbitRPC::Message
- Defined in:
- lib/rabbit_rpc/message.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Class Method Summary collapse
- .generate_id ⇒ Object
-
.unpack(message) ⇒ Object
Unpacks a serialized message to a hash containing the method and its args.
Instance Method Summary collapse
-
#initialize(method_name, *args) ⇒ Message
constructor
A new instance of Message.
-
#pack ⇒ Object
Squeezes and serializes the RPC method name and arguments.
Constructor Details
#initialize(method_name, *args) ⇒ Message
Returns a new instance of Message.
8 9 10 11 |
# File 'lib/rabbit_rpc/message.rb', line 8 def initialize(method_name, *args) @method_name = method_name @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/rabbit_rpc/message.rb', line 6 def args @args end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
6 7 8 |
# File 'lib/rabbit_rpc/message.rb', line 6 def method_name @method_name end |
Class Method Details
.generate_id ⇒ Object
29 30 31 |
# File 'lib/rabbit_rpc/message.rb', line 29 def self.generate_id SecureRandom.uuid end |
.unpack(message) ⇒ Object
Unpacks a serialized message to a hash containing the method and its args. This method needs to be modified if a serializer other than MessagePack is to be used.
Returns a Hash
25 26 27 |
# File 'lib/rabbit_rpc/message.rb', line 25 def self.unpack() MessagePack.unpack end |
Instance Method Details
#pack ⇒ Object
Squeezes and serializes the RPC method name and arguments
Returns the packed and serialized string
16 17 18 |
# File 'lib/rabbit_rpc/message.rb', line 16 def pack serialize(method: @method_name, args: @args) end |