You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: with_events.rb
    path of file: ./repos/rails-graphql/lib/rails/graphql/helpers
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Rails
  module GraphQL
    module Helpers
      # Helper module that allows other objects to hold events, either from a
      # singleton point-of-view, or for instances
      module WithEvents
        def self.extended(other)
          other.extend(Helpers::InheritedCollection)
          other.extend(WithEvents::FixedTypes)

          other.inherited_collection(:events, type: :hash_array)
          other.inhe
    
        def on(event_name, callback = nil, unshift: false, &block)
          event_name = event_name.to_sym
          valid = !event_types || event_types.include?(event_name)
          raise ArgumentError, (+<<~MSG).squish unless valid
            The #{event_name} is not a valid event type.
          MSG

          invalid_callback = callback.nil? || callback.is_a?(Callback)
          raise ArgumentError, (+<<~MSG).squish unless invalid_callback
            The provided #{callback.class.name} is not a valid callback.
          MSG

          listeners << event_name
          events[event_name].send(unshift ? :unshift : :push, callback || block)
          self
        end