Class: Moleculer::Packets::Res
- Defined in:
- lib/moleculer/packets/res.rb
Overview
Represents a RES packet
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(config, data) ⇒ Res
constructor
A new instance of Res.
- #to_h ⇒ Object
- #topic ⇒ Object
Methods inherited from Base
inherited, packet_accessors, packet_attr, packet_name, #sender, #ver
Constructor Details
#initialize(config, data) ⇒ Res
Returns a new instance of Res.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/moleculer/packets/res.rb', line 15 def initialize(config, data) super(config, data) @id = HashUtil.fetch(data, :id) @success = HashUtil.fetch(data, :success) @data = HashUtil.fetch(data, :data) @error = HashUtil.fetch(data, :error, nil) @meta = HashUtil.fetch(data, :meta) @stream = HashUtil.fetch(data, :stream, false) @node = HashUtil.fetch(data, :node, nil) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/moleculer/packets/res.rb', line 8 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/moleculer/packets/res.rb', line 8 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/moleculer/packets/res.rb', line 8 def id @id end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
8 9 10 |
# File 'lib/moleculer/packets/res.rb', line 8 def @meta end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
8 9 10 |
# File 'lib/moleculer/packets/res.rb', line 8 def stream @stream end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
8 9 10 |
# File 'lib/moleculer/packets/res.rb', line 8 def success @success end |
Instance Method Details
#to_h ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/moleculer/packets/res.rb', line 31 def to_h super.merge( id: @id, success: @success, data: @data, error: @error, meta: @meta, stream: @stream, ) end |
#topic ⇒ Object
27 28 29 |
# File 'lib/moleculer/packets/res.rb', line 27 def topic "#{super}.#{@node.id}" end |