Sha256: 88d2e0905d0fec92eda8a1ce4fd0eff9deeb304654631f8daa39c60f619e580b

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

# encoding: UTF-8

require 'singleton'

module Watchmaker # :nodoc:

  # Singleton configuration class to hold all configured information.
  #
  class Configuration

    include Singleton

    # Store list of all profiles.
    #
    attr_accessor :profiles

    # Initialize to an empty hash.
    #
    def initialize 
      @profiles = {}
    end

    class << self 
      def define(name, dependencies, &block) 
        instance.define(name, dependencies, &block)
      end

      alias :learn :define

      def defined(name)
        instance.defined(name)
      end

      alias :learned :defined

      def defined?(name)
        !!defined(name)
      end

      alias :learned? :defined?
    end

    def define(name, dependencies, &block) # :nodoc:
      @profiles[name] = { 
        :dependencies => dependencies,
        :block        => block
      }
    end

    alias :learn :define

    def defined(name) # :nodoc:
      @profiles[name]
    end

    alias :learned :defined

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watchmaker-0.2.2 lib/watchmaker/configuration.rb
watchmaker-0.2.1 lib/watchmaker/configuration.rb
watchmaker-0.2.0 lib/watchmaker/configuration.rb