Module: MobRotation::CommandRouting

Included in:
Rotation
Defined in:
lib/mob_rotation/command_routing.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

COMMAND_MAPPINGS =
{}

Instance Method Summary collapse

Instance Method Details

#command_router(command, mobster_names) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mob_rotation/command_routing.rb', line 11

def command_router(command, mobster_names)
  command_implementation = CommandRouting::COMMAND_MAPPINGS.fetch(command) {
    lambda { |command|
      inform_lovely_user(command)
    }
  }
  case command_implementation.arity
  when -2
    instance_exec(command, *mobster_names, &command_implementation)
  when -1
    instance_exec(*mobster_names, &command_implementation)
  when 1
    instance_exec(command, &command_implementation)
  else
    instance_exec(&command_implementation)
  end
end