Module: AyeCommander::Commander

Extended by:
ClassMethods
Includes:
Command
Defined in:
lib/aye_commander/commander.rb

Overview

Commander is a special command that lets you run several command in a succession. At the end it returns its own result containing a hash with the commands run.

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Limitable::ClassMethods

Limitable::ClassMethods::LIMITERS

Constants included from Hookable::ClassMethods

Hookable::ClassMethods::TYPES

Instance Attribute Summary

Attributes included from Status::Writeable

#status

Attributes included from Status::Readable

#status

Instance Method Summary collapse

Methods included from ClassMethods

abort_on_failure, abort_on_failure?, command, executes, included, inherited, prepare_commander_result

Methods included from Status::ClassMethods

#succeeds, #succeeds_with

Methods included from Shareable::ClassMethods

#included, #inherited

Methods included from Resultable::ClassMethods

#new_result, #result, #result_class

Methods included from Limitable::ClassMethods

#limiters, #readers, #uses, #validate_arguments, #validate_received_arguments, #validate_received_arguments?, #validate_required_arguments, #validate_required_arguments?

Methods included from Ivar::ClassMethods

#at, #define_missing_reader, #eq, #to_ivar, #to_nvar

Methods included from Abortable::ClassMethods

#abortable

Methods included from Status::Writeable

#fail!

Methods included from Status::Readable

#failure?, #success?

Methods included from Ivar::Writeable

#method_missing

Methods included from Ivar::Readable

#method_missing, #remove!, #to_ivar, #to_nvar

Methods included from Inspectable

#inspect, #pretty_print, #sorted_instance_variables, #to_hash, #to_result_hash

Methods included from Abortable

#abort!

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AyeCommander::Ivar::Writeable

Instance Method Details

#callObject

This is the default call for a commander It basically just executes the commands saved in the executes array. This however can be overwritten by the user and define their own logic to execute different commands


95
96
97
# File 'lib/aye_commander/commander.rb', line 95

def call
  execute(*self.class.executes, abort_on_failure: true)
end

#initialize(**args) ⇒ Object

A commander works with the following instance variables: command: The last executed command. Will be an anonymous empty command at

the beginning

executed: An array containing the executed commands


87
88
89
# File 'lib/aye_commander/commander.rb', line 87

def initialize(**args)
  super(command: self.class.command.new(args), executed: [])
end