Class: FoundationKit::CompositeCommand

Inherits:
BaseClass
  • Object
show all
Defined in:
lib/foundation_kit/composite_command.rb

Overview

Implements the Composite Command design pattern.

Author:

  • jcrum

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseClass

#to_h, #to_s

Constructor Details

#initialize(**args) ⇒ FoundationKit::CompositeCommand

Creates an instance of the Composite Command . post initialization hooks.

Parameters:

  • **args

    Additional arguments used for subclasses to pass to



19
20
21
22
23
# File 'lib/foundation_kit/composite_command.rb', line 19

def initialize(**args)
  @commands = []

  super(args)
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



10
11
12
# File 'lib/foundation_kit/composite_command.rb', line 10

def commands
  @commands
end

Instance Method Details

#add_command(command) ⇒ Object

Adds a command for execution . extends FoundationKit::Command

Parameters:



30
31
32
# File 'lib/foundation_kit/composite_command.rb', line 30

def add_command(command)
  commands << command
end

#executeObject

TODO:

Implement execution order

Executes the commands



39
40
41
# File 'lib/foundation_kit/composite_command.rb', line 39

def execute
  commands.each(&:execute)
end