Sha256: f64c2900e99b1a86d6f15289ab14441bfca40d8018fd45d6bef40ad5edbc77f4

Contents?: true

Size: 712 Bytes

Versions: 3

Compression:

Stored size: 712 Bytes

Contents

module Aruba
  class Config
    attr_reader :hooks

    def initialize
      @hooks = Hooks.new
    end

    # Register a hook to be called before Aruba runs a command
    def before_cmd(&block)
      @hooks.append(:before_cmd, block)
    end
  end

  #nodoc
  class Hooks
    def initialize
      @store = Hash.new do |hash, key|
        hash[key] = []
      end
    end

    def append(label, block)
      @store[label] << block
    end

    def execute(label, context, *args)
      @store[label].each do |block|
        context.instance_exec(*args, &block)
      end
    end
  end

  class << self
    attr_accessor :config

    def configure
      yield config
    end

  end

  self.config = Config.new
end

Version data entries

3 entries across 2 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/aruba-0.6.2/lib/aruba/config.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/aruba-0.6.2/lib/aruba/config.rb
aruba-0.6.2 lib/aruba/config.rb