Class: Swat::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/swat.rb

Overview

Defines the basic behavior of a command

Inherith to reuse all this logic, only pre-check and execute are mandatory methods the rest can be as is

Use the context object to send state from one stage to the next

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ BaseCommand

Returns a new instance of BaseCommand.



14
15
16
# File 'lib/swat.rb', line 14

def initialize(args)
  @args = args
end

Instance Method Details

#execute(_context) ⇒ Object



26
27
28
# File 'lib/swat.rb', line 26

def execute(_context)
  fail "Execution is not defined"
end

#pre_check(_context) ⇒ Object



22
23
24
# File 'lib/swat.rb', line 22

def pre_check(_context)
  fail "PreChecks are not defined"
end

#prepare(_context) ⇒ Object



18
19
20
# File 'lib/swat.rb', line 18

def prepare(_context)
  # validate arguments here
end