Class: Droonga::CommandMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/command_mapper.rb

Instance Method Summary collapse

Constructor Details

#initializeCommandMapper

Returns a new instance of CommandMapper.



20
21
22
# File 'lib/droonga/command_mapper.rb', line 20

def initialize
  @commands = {}
end

Instance Method Details

#[](command) ⇒ Object



37
38
39
# File 'lib/droonga/command_mapper.rb', line 37

def [](command)
  @commands[command.to_s]
end

#commandsObject



41
42
43
# File 'lib/droonga/command_mapper.rb', line 41

def commands
  @commands.keys
end

#register(name_or_map) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/droonga/command_mapper.rb', line 24

def register(name_or_map)
  if name_or_map.is_a?(Hash)
    command_map = name_or_map
    command_map.each do |command_name, method_name|
      @commands[command_name.to_s] = method_name
    end
  else
    name = name_or_map
    method_name = name
    @commands[name.to_s] = method_name
  end
end