Module: Adama::Invoker::InvokeMethods

Defined in:
lib/adama/invoker.rb

Overview

Our new class methods enable us to set the command list

Instance Method Summary collapse

Instance Method Details

#commandsObject

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



62
63
64
# File 'lib/adama/invoker.rb', line 62

def commands
  @commands ||= []
end

#invoke(*command_list) ⇒ Object

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



52
53
54
55
56
57
58
# 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