Class: OnyxCord::Events::RawDispatchHandler
- Inherits:
-
Object
- Object
- OnyxCord::Events::RawDispatchHandler
- Defined in:
- lib/onyxcord/events/raw/base.rb
Overview
Handler for raw Gateway payloads. This bypasses Event object allocation and receives the original parsed Gateway packet.
Instance Method Summary collapse
- #call(packet) ⇒ Object
-
#initialize(filter, block) ⇒ RawDispatchHandler
constructor
A new instance of RawDispatchHandler.
- #matches?(packet) ⇒ Boolean
Constructor Details
#initialize(filter, block) ⇒ RawDispatchHandler
Returns a new instance of RawDispatchHandler.
52 53 54 55 |
# File 'lib/onyxcord/events/raw/base.rb', line 52 def initialize(filter, block) @filter = filter @block = block end |
Instance Method Details
#call(packet) ⇒ Object
70 71 72 |
# File 'lib/onyxcord/events/raw/base.rb', line 70 def call(packet) @block.call(packet) end |
#matches?(packet) ⇒ Boolean
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/onyxcord/events/raw/base.rb', line 57 def matches?(packet) return true unless @filter type = packet['t'] || packet[:t] return false unless type if @filter.is_a?(Regexp) @filter.match?(type) else type.to_s.casecmp(@filter.to_s).zero? end end |