Class: OsCtld::Command

Inherits:
Object
  • Object
show all
Includes:
OsCtl::Lib::Utils::Log
Defined in:
lib/osctld/command.rb

Direct Known Subclasses

Migration::Command, UserControl::Command

Constant Summary collapse

@@commands =
{}
@@cmd_id =
Concurrent::AtomicFixnum.new(0)

Class Method Summary collapse

Class Method Details

.find(handle) ⇒ Object



21
22
23
# File 'lib/osctld/command.rb', line 21

def self.find(handle)
  @@commands[self][handle]
end

.get_idObject



25
26
27
# File 'lib/osctld/command.rb', line 25

def self.get_id
  @@cmd_id.increment
end

.register(name, klass) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/osctld/command.rb', line 11

def self.register(name, klass)
  @@commands[self] ||= {}

  if @@commands[self].has_key?(name)
    raise "Command '#{name}' is already handled by class '#{@@commands[self][name]}'"
  end

  @@commands[self][name] = klass
end