Sha256: 68cad5c26fe0cf62b4cd961394876b1dc4d721d6a784f4830f8bcf84fdef03df

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

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

    def self.learn(name, dependencies, &block) 
      instance.learn(name, dependencies, &block)
    end

    def self.learned(name)
      instance.learned(name)
    end

    def self.learned?(name)
      !!learned(name)
    end

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

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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watchmaker-0.1.2 lib/watchmaker/configuration.rb
watchmaker-0.1.1 lib/watchmaker/configuration.rb