Class: FoundationKit::Command

Inherits:
BaseClass show all
Defined in:
lib/foundation_kit/command.rb

Overview

Implements an abstract class for the command design pattern.

Author:

  • jcrum

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseClass

#to_h, #to_s

Constructor Details

#initialize(description: nil, execution_order: nil, **args) ⇒ FoundationKit::Command

Creates an instance of the Command class

. if it is part of a composite command exection plan and order matters. . post initialization hooks.

Parameters:

  • description: (defaults to: nil)

    nil [String] Description of the command.

  • execution_order: (defaults to: nil)

    nil [Integer] Used to determine order of execution

  • **args

    Additional arguments used for subclasses to pass to



24
25
26
27
28
29
30
# File 'lib/foundation_kit/command.rb', line 24

def initialize(description: nil, execution_order: nil, **args)
  @description = description
  @execution_order = execution_order
  @success = false

  super(description: description, execution_order: execution_order, **args)
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#execution_orderObject (readonly)

Returns the value of attribute execution_order.



11
12
13
# File 'lib/foundation_kit/command.rb', line 11

def execution_order
  @execution_order
end

#resultObject (readonly)

Returns the value of attribute result.



12
13
14
# File 'lib/foundation_kit/command.rb', line 12

def result
  @result
end

Instance Method Details

#success?Boolean

Successful execution checker

Returns:

  • (Boolean)

    Was the execution of the command successful?



43
44
45
# File 'lib/foundation_kit/command.rb', line 43

def success?
  @success || false
end