class Discordrb::Events::EventHandler

Generic event handler that can be extended

Public Class Methods

new(attributes, block) click to toggle source
# File lib/discordrb/events/generic.rb, line 78
def initialize(attributes, block)
  @attributes = attributes
  @block = block
end

Public Instance Methods

after_call(event) click to toggle source

to be overwritten by extending event handlers

# File lib/discordrb/events/generic.rb, line 102
def after_call(event); end
call(event) click to toggle source

Calls this handler @param event [Object] The event object to call this handler with

# File lib/discordrb/events/generic.rb, line 97
def call(event)
  @block.call(event)
end
match(event) click to toggle source

Checks whether this handler matches the given event, and then calls it. @param event [Object] The event object to match and call the handler with

# File lib/discordrb/events/generic.rb, line 91
def match(event)
  call(event) if matches? event
end
matches?(_) click to toggle source

Whether or not this event handler matches the given event with its attributes. @raise [RuntimeError] if this method is called - overwrite it in your event handler!

# File lib/discordrb/events/generic.rb, line 85
def matches?(_)
  raise 'Attempted to call matches?() from a generic EventHandler'
end
matches_all(attributes, to_check, &block) click to toggle source

@see Discordrb::Events::matches_all

# File lib/discordrb/events/generic.rb, line 105
def matches_all(attributes, to_check, &block)
  Discordrb::Events.matches_all(attributes, to_check, &block)
end