Module: Lhm::Command

Included in:
AtomicSwitcher, Chunker, Entangler, LockedSwitcher, Migrator, Throttler::Time
Defined in:
lib/lhm/command.rb

Instance Method Summary collapse

Instance Method Details

#run(&block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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