Module: LateCommands
- Included in:
- Commands
- Defined in:
- lib/late_commands.rb,
lib/late_commands/version.rb,
lib/late_commands/commands.rb
Defined Under Namespace
Classes: Commands, InvalidCommandError, UnknownCommandError
Constant Summary
collapse
- VERSION =
"0.1.0"
Instance Method Summary
collapse
Instance Method Details
#command_method_name=(value) ⇒ Object
23
24
25
|
# File 'lib/late_commands.rb', line 23
def command_method_name=(value)
@command_method_name = value
end
|
#execute_command(command_name, *args) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/late_commands.rb', line 15
def execute_command(command_name, *args)
command = commands[command_name]
raise UnknownCommandError, "Unknown command :#{command_name}" unless command
return command.call(*args) if command.instance_of? Proc
command.public_send command_method_name, *args
end
|
#register_command(command_name, command) ⇒ Object
10
11
12
13
|
# File 'lib/late_commands.rb', line 10
def register_command(command_name, command)
check_command command
commands[command_name] = command
end
|