Module: Fum::CommandManager::ClassMethods

Defined in:
lib/fum/command_manager.rb

Constant Summary collapse

@@commands_map =
Hash.new

Instance Method Summary collapse

Instance Method Details

#command(name, opts = {}) ⇒ Object



8
9
10
11
12
# File 'lib/fum/command_manager.rb', line 8

def command(name, opts={})
  require "fum/commands/#{name}"
  class_name = name.to_s.capitalize
  @@commands_map[name] = Fum::Commands::const_get(class_name)
end

#create_commands(*args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/fum/command_manager.rb', line 14

def create_commands(*args)
  map = {}
  @@commands_map.each { |key, value|
    map[key] = value.new(*args)
  }
  map
end