Module Commands::Dispatchers
In: commands/dispatcher.rb
commands/dispatchers/simple.rb
commands/dispatchers/namespace.rb

This module contains both the interface and the implementations for the different dispatchers provided.

A dispatcher is an object that can handle user request and perform actions. There is no limit in the amount or nature that a dispatcher can perform.

To create a dispatcher you only need to implement the DispatcherInterface.

Two implementations of the interface are provided:

  • Simple: designed as the easiest way to implement the interface, classes inheriting from this dispatcher will only need to declare a list of keywords and provide the functions associated to them.
  • Namespace: sometimes a single keyword is not enough to clearly identify an action. Say for example we want the user to be able to type: add host but also: add protocol. Since both actions are related to adding something we want them to be handled by the same dispatcher, so we inherit from Namespace and set the :namespace setting to "add". Then we will need to implement the two methods (host, protocol) as if we were working with a Simple dispatcher.

Classes and Modules

Module Commands::Dispatchers::DispatcherInterface
Class Commands::Dispatchers::Namespace
Class Commands::Dispatchers::Simple

[Validate]