Class: Async::Bus::Protocol::Invoke

Inherits:
Object
  • Object
show all
Defined in:
lib/async/bus/protocol/invoke.rb

Overview

Represents a method invocation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, arguments, options, block_given) ⇒ Invoke

Initialize a new invocation message.



20
21
22
23
24
25
26
# File 'lib/async/bus/protocol/invoke.rb', line 20

def initialize(id, name, arguments, options, block_given)
  @id = id
  @name = name
  @arguments = arguments
  @options = options
  @block_given = block_given
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



35
36
37
# File 'lib/async/bus/protocol/invoke.rb', line 35

def arguments
  @arguments
end

#block_givenObject (readonly)

Returns the value of attribute block_given.



41
42
43
# File 'lib/async/bus/protocol/invoke.rb', line 41

def block_given
  @block_given
end

#idObject (readonly)

Returns the value of attribute id.



29
30
31
# File 'lib/async/bus/protocol/invoke.rb', line 29

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/async/bus/protocol/invoke.rb', line 32

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



38
39
40
# File 'lib/async/bus/protocol/invoke.rb', line 38

def options
  @options
end

#The positional arguments.(positionalarguments.) ⇒ Object (readonly)



35
# File 'lib/async/bus/protocol/invoke.rb', line 35

attr :arguments

#The transaction ID.(transactionID.) ⇒ Object (readonly)



29
# File 'lib/async/bus/protocol/invoke.rb', line 29

attr :id

Class Method Details

.unpack(unpacker) ⇒ Object

Unpack an invocation from a MessagePack unpacker.



66
67
68
69
70
71
72
73
74
# File 'lib/async/bus/protocol/invoke.rb', line 66

def self.unpack(unpacker)
  id = unpacker.read
  name = unpacker.read
  arguments = Array.new(unpacker.read){unpacker.read}
  options = Array.new(unpacker.read){[unpacker.read, unpacker.read]}.to_h
  block_given = unpacker.read
  
  return self.new(id, name, arguments, options, block_given)
end

Instance Method Details

#pack(packer) ⇒ Object

Pack the invocation into a MessagePack packer.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/async/bus/protocol/invoke.rb', line 45

def pack(packer)
  packer.write(@id)
  packer.write(@name)
  
  packer.write(@arguments.size)
  @arguments.each do |argument|
    packer.write(argument)
  end
  
  packer.write(@options.size)
  @options.each do |key, value|
    packer.write(key)
    packer.write(value)
  end
  
  packer.write(@block_given)
end

#The keyword arguments.=(keywordarguments. = (value)) ⇒ Object



38
# File 'lib/async/bus/protocol/invoke.rb', line 38

attr :options

#The method name.=(methodname. = (value)) ⇒ Object



32
# File 'lib/async/bus/protocol/invoke.rb', line 32

attr :name

#Whether a block was provided.=(ablockwasprovided. = (value)) ⇒ Object



41
# File 'lib/async/bus/protocol/invoke.rb', line 41

attr :block_given