Class: DevSystem::BaseCommand
- Inherits:
-
Command
- Object
- Liza::Unit
- Liza::Controller
- Command
- DevSystem::BaseCommand
- Defined in:
- lib/dev_system/sub/command/commands/base_command.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Liza::Controller
color, inherited, on_connected
Methods inherited from Liza::Unit
const_missing, division, part, system, #system, test_class
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
14 15 16 |
# File 'lib/dev_system/sub/command/commands/base_command.rb', line 14 def env @env end |
Class Method Details
.call(env) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/dev_system/sub/command/commands/base_command.rb', line 5 def self.call(env) log :lower, "env.count is #{env.count}" command = env[:command] = new command.call env end |
.get_command_signatures ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dev_system/sub/command/commands/base_command.rb', line 31 def self.get_command_signatures signatures = [] ancestors_until(BaseCommand).each do |c| signatures += c.instance_methods_defined.select do |name| name.start_with? "call_" end.map do |name| OpenStruct.new({ name: ( name.to_s.sub("call_", "").sub("default", "") ), description: "# no description", }) end end signatures end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dev_system/sub/command/commands/base_command.rb', line 16 def call(env) log :lower, "env.count is #{env.count}" @env = env method_name = env[:command_arg] method_name = method_name.split(":")[1] || :default method_name = "call_#{method_name}" return public_send method_name if respond_to? method_name log "method not found: #{method_name.inspect}" raise NoMethodError, "method not found: #{method_name.inspect}" end |