Class: Rubycord::Events::ChannelCreateEventHandler

Inherits:
EventHandler
  • Object
show all
Defined in:
lib/rubycord/events/channels.rb

Overview

Event handler for ChannelCreateEvent

Direct Known Subclasses

ChannelUpdateEventHandler

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #initialize, #match, #matches_all

Constructor Details

This class inherits a constructor from Rubycord::Events::EventHandler

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rubycord/events/channels.rb', line 38

def matches?(event)
  # Check for the proper event type
  return false unless event.is_a? ChannelCreateEvent

  [
    matches_all(@attributes[:type], event.type) do |a, e|
      a == if a.is_a? String
        e.name
      else
        e
      end
    end,
    matches_all(@attributes[:name], event.name) do |a, e|
      a == if a.is_a? String
        e.to_s
      else
        e
      end
    end
  ].reduce(true, &:&)
end