Sha256: b164369a35e3b41af0aade7e3c4a6d7dc0538081f8162b9c1c1400dc3f0cae08

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 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_run(&block)
      @hooks.append(:before_run, 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, *args, context)
      @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

1 entries across 1 versions & 1 rubygems

Version Path
aruba-0.4.8 lib/aruba/config.rb