Class: FoundationKit::CompositeCommand
- Defined in:
- lib/foundation_kit/composite_command.rb
Overview
Implements the Composite Command design pattern.
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Instance Method Summary collapse
-
#add_command(command) ⇒ Object
Adds a command for execution .
-
#execute ⇒ Object
Executes the commands.
-
#initialize(**args) ⇒ FoundationKit::CompositeCommand
constructor
Creates an instance of the Composite Command .
Methods inherited from BaseClass
Constructor Details
#initialize(**args) ⇒ FoundationKit::CompositeCommand
Creates an instance of the Composite Command . post initialization hooks.
19 20 21 22 23 |
# File 'lib/foundation_kit/composite_command.rb', line 19 def initialize(**args) @commands = [] super(args) end |
Instance Attribute Details
#commands ⇒ Object (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
30 31 32 |
# File 'lib/foundation_kit/composite_command.rb', line 30 def add_command(command) commands << command end |
#execute ⇒ Object
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 |