Class: Controll::Commander

Inherits:
Object
  • Object
show all
Extended by:
Imperator::Command::MethodFactory
Defined in:
lib/controll/commander.rb

Overview

used to register commands for a controller

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(initiator, options = {}) ⇒ Commander

Returns a new instance of Commander.



9
10
11
12
# File 'lib/controll/commander.rb', line 9

def initialize initiator, options = {}
  @initiator = initiator
  @options = options
end

Instance Attribute Details

#initiatorObject (readonly) Also known as: controller

Returns the value of attribute initiator.



7
8
9
# File 'lib/controll/commander.rb', line 7

def initiator
  @initiator
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/controll/commander.rb', line 7

def options
  @options
end

Class Method Details

.initiator_methods(*names) ⇒ Object Also known as: controller_methods



27
28
29
# File 'lib/controll/commander.rb', line 27

def initiator_methods *names
  delegate names, to: :initiator
end

Instance Method Details

#command(name, *args) ⇒ Object



14
15
16
# File 'lib/controll/commander.rb', line 14

def command name, *args
  send "#{name}_command", *args
end

#command!(name, *args) ⇒ Object Also known as: use_command, perform_command



18
19
20
# File 'lib/controll/commander.rb', line 18

def command! name, *args
  command(name, *args).perform
end