module Adama::Command

Extend class with module methods

class CollectUnderpantsCommand

include Adama::Command

def call
  got_get_underpants()
end

def rollback
  return_underpants_to_rightful_owner()
end

end

Public Class Methods

included(base) click to toggle source

Internal: Install Command's behavior in the given class.

# File lib/adama/command.rb, line 17
def self.included(base)
  base.class_eval do
    prepend Validator
    extend ClassMethods
    attr_reader :kwargs
  end
end
new(**kwargs) click to toggle source
# File lib/adama/command.rb, line 32
def initialize(**kwargs)
  @kwargs = kwargs
end

Public Instance Methods

call() click to toggle source

Public instance method. Override this in classes this module is included in.

# File lib/adama/command.rb, line 50
def call; end
rollback() click to toggle source

Public instance method. Override this in classes this module is included in.

# File lib/adama/command.rb, line 54
def rollback; end
run() click to toggle source

Internal instance method. Called by both the call class method, and by the call method in the invoker. If it fails it raises a CommandError.

# File lib/adama/command.rb, line 38
def run
  tap(&:call)
rescue => error
  raise Errors::CommandError.new(
    error: error,
    command: self,
    backtrace: error.backtrace
  )
end