Sha256: ed3d990d0e4e25d866ed826f1dd2f92032903d3ff3a857cc1dc1f180df1c8eea

Contents?: true

Size: 606 Bytes

Versions: 3

Compression:

Stored size: 606 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)
      validate

      if(block_given?)
        before
        block.call(self)
        after
      else
        execute
      end
    rescue
      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

3 entries across 3 versions & 1 rubygems

Version Path
lhm-2.0.0 lib/lhm/command.rb
lhm-1.3.0 lib/lhm/command.rb
lhm-1.2.0 lib/lhm/command.rb