module Adama::Invoker::InvokeMethods

Our new class methods enable us to set the command list

Public Instance Methods

commands() click to toggle source

internal class method. So we can loop through the commands that have been assigned by the including class.

# File lib/adama/invoker.rb, line 62
def commands
  @commands ||= []
end
invoke(*command_list) click to toggle source

Public class method. Call invoke in your class definition to specify which commands will be executed.

class SuccessfulBusinessCreator

include Adama::Invoker

invoke(
  CollectUnderpantsCommand,
  MagicHappensCommand,
  ProfitCommand,
)

end

# File lib/adama/invoker.rb, line 52
def invoke(*command_list)
  if is_a?(Invoker) && self.class.commands.any?
    raise(StandardError, 'Can\'t call invoke on an Invoker instance \
                         with a class invocation list.')
  end
  @commands = command_list.flatten
end