module Lhm::Command

Public Instance Methods

run(&block) click to toggle source
# File lib/lhm/command.rb, line 9
def run(&block)
  Lhm.logger.info "Starting run of class=#{self.class}"
  validate

  if block_given?
    before
    block.call(self)
    after
  else
    execute
  end
rescue => e
  Lhm.logger.error "Error in class=#{self.class}, reverting. exception=#{e.class} message=#{e.message}"
  revert
  raise
end

Private Instance Methods

after() click to toggle source
# File lib/lhm/command.rb, line 41
def after
end
before() click to toggle source
# File lib/lhm/command.rb, line 38
def before
end
error(msg) click to toggle source
# File lib/lhm/command.rb, line 44
def error(msg)
  raise Error.new(msg)
end
execute() click to toggle source
# File lib/lhm/command.rb, line 34
def execute
  raise NotImplementedError.new(self.class.name)
end
revert() click to toggle source
# File lib/lhm/command.rb, line 31
def revert
end
validate() click to toggle source
# File lib/lhm/command.rb, line 28
def validate
end