Class | MacroCommand |
In: |
src/org/puremvc/ruby/patterns/command/macro_command.rb
|
Parent: | Object |
A MacroCommand maintains an list of Command Class references called SubCommands
When execute is called, the MacroCommand instantiates and calls execute on each of its SubCommands.Each SubCommand will be passed a reference to the original Notification that was passed to the MacroCommand‘s execute method.
Unlike SimpleCommand, your subclass should not override execute, but instead, should override the initialize_macro_command method, calling add_sub_command once for each SubCommand to be executed.
sub_commands | [RW] |
You should not need to define a constructor, instead, override the initialize_macro_command method.
If your subclass does define a constructor, be sure to call super.
Execute this MacroCommand‘s Subcommands. The SubCommands will be called in First In/First Out (FIFO) order.
Initialize the MacroCommand.
In your subclass, override this method to initialize the MacroCommand‘s SubCommand list with Command class references like this:
<tt>
def initialize_macro_command add_sub_command( FirstCommand.new ) add_sub_command( SecondCommand.new ) add_sub_command( ThirdCommand.new ) end
</tt>
Note that SubCommands may be MacroCommands or SimpleCommands.