Module: AdvancedRubyCommandHandler::EventHandler

Defined in:
lib/advanced_ruby_command_handler/app/event_handler.rb

Class Method Summary collapse

Class Method Details

.load_events(client) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/advanced_ruby_command_handler/app/event_handler.rb', line 7

def self.load_events(client)
  events = []
  Dir.entries(client.events_dir).each do |file|
    next if %w[. ..].include?(file)

    load "#{client.events_dir}/#{file}"
    events << File.basename(file, ".rb")
  end

  Dir["#{File.dirname(__FILE__)}/defaults/events/*.rb"].sort.each do |file|
    next if events.include?(File.basename(file, ".rb"))

    require file

    events << File.basename(file, ".rb")
  end

  events
end