discorb-lib/discorb

View on GitHub
sig/discorb/event_handler.rbs

Summary

Maintainability
Test Coverage
module Discorb
  #
  # Represents a event handler.
  # This class shouldn't be instantiated directly.
  # Use {Client#on} instead.
  class EventHandler
    def initialize: (untyped block, Symbol? id, untyped metadata) -> void

    %a{pure}
    def inspect: -> String

    #
    # Calls the block associated with the event.
    def call: (*untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped

    # @return [Proc] the block to be called.
    attr_reader block: ^(*untyped) -> void

    # @return [Symbol] the event id.
    attr_reader id: Symbol?

    # @return [Hash] the event metadata.
    attr_reader metadata: ::Hash[untyped, untyped]

    # @return [Boolean] whether the event is once or not.
    attr_reader once: bool
  end
end