Sha256: 335a23820697cf2d72de0d02d6c03545c1d95fe09609db7f571c0f27f2b1da1b

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt

module Lhm
  class Error < StandardError
  end

  module Command
    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

    def validate
    end

    def revert
    end

    def execute
      raise NotImplementedError.new(self.class.name)
    end

    def before
    end

    def after
    end

    def error(msg)
      raise Error.new(msg)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lhm-2.2.0 lib/lhm/command.rb