Sha256: ec291c2448970264fe24722fdc73a1b82e2a7bb7538293c8615e3fd5a6a2175a

Contents?: true

Size: 780 Bytes

Versions: 27

Compression:

Stored size: 780 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

27 entries across 27 versions & 2 rubygems

Version Path
lhm-shopify-4.4.2 lib/lhm/command.rb
lhm-shopify-4.4.1 lib/lhm/command.rb
lhm-shopify-4.4.0 lib/lhm/command.rb
lhm-shopify-4.3.0 lib/lhm/command.rb
lhm-shopify-4.2.3 lib/lhm/command.rb
lhm-shopify-4.2.2 lib/lhm/command.rb
lhm-shopify-4.2.1 lib/lhm/command.rb
lhm-shopify-4.2.0 lib/lhm/command.rb
lhm-shopify-4.1.1 lib/lhm/command.rb
lhm-shopify-4.1.0 lib/lhm/command.rb
lhm-shopify-4.0.0 lib/lhm/command.rb
lhm-teak-3.6.4 lib/lhm/command.rb
lhm-teak-3.6.3 lib/lhm/command.rb
lhm-teak-3.6.2 lib/lhm/command.rb
lhm-teak-3.6.1 lib/lhm/command.rb
lhm-teak-3.6.0 lib/lhm/command.rb
lhm-shopify-3.5.5 lib/lhm/command.rb
lhm-shopify-3.5.4 lib/lhm/command.rb
lhm-shopify-3.5.3 lib/lhm/command.rb
lhm-shopify-3.5.2 lib/lhm/command.rb