Class: Moleculer::Packets::Event
- Defined in:
- lib/moleculer/packets/event.rb
Overview
Represents a EVENT packet
Instance Attribute Summary collapse
-
#broadcast ⇒ Object
readonly
Returns the value of attribute broadcast.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(config, data = {}) ⇒ Event
constructor
A new instance of Event.
- #to_h ⇒ Object
- #topic ⇒ Object
Methods inherited from Base
inherited, packet_accessors, packet_attr, packet_name, #sender, #ver
Constructor Details
#initialize(config, data = {}) ⇒ Event
Returns a new instance of Event.
15 16 17 18 19 20 21 22 23 |
# File 'lib/moleculer/packets/event.rb', line 15 def initialize(config, data = {}) super(config, data) @event = HashUtil.fetch(data, :event) @data = HashUtil.fetch(data, :data) @broadcast = HashUtil.fetch(data, :broadcast) @groups = HashUtil.fetch(data, :groups, []) @node = HashUtil.fetch(data, :node, nil) end |
Instance Attribute Details
#broadcast ⇒ Object (readonly)
Returns the value of attribute broadcast.
10 11 12 |
# File 'lib/moleculer/packets/event.rb', line 10 def broadcast @broadcast end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/moleculer/packets/event.rb', line 10 def data @data end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
10 11 12 |
# File 'lib/moleculer/packets/event.rb', line 10 def event @event end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
10 11 12 |
# File 'lib/moleculer/packets/event.rb', line 10 def groups @groups end |
Instance Method Details
#to_h ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/moleculer/packets/event.rb', line 25 def to_h super.merge( event: @event, data: @data, broadcast: @broadcast, groups: @groups, ) end |
#topic ⇒ Object
34 35 36 |
# File 'lib/moleculer/packets/event.rb', line 34 def topic "#{super}.#{@node.id}" end |