Sha256: 6c33762024d773c7f723934098e6ea3918ca47b34422fdae92181181c1126069

Contents?: true

Size: 1.66 KB

Versions: 39

Compression:

Stored size: 1.66 KB

Contents

# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
#
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
# reproduction, modification, or disclosure of this program is
# strictly prohibited. Any use of this program by an authorized
# licensee is strictly subject to the terms and conditions,
# including confidentiality obligations, set forth in the applicable
# License Agreement between RightScale.com, Inc. and
# the licensee

module RightConf

  # Configurator mixin, defines DSL and common validation method
  class ConfiguratorRegistry

    include Singleton

    # Associate configurator with given key
    #
    # === Parameters
    # key(Symbol):: Key configurator should be associated with
    # value(Class):: Associated configurator class
    #
    # === Return
    # value(Class):: Configurator class
    def []=(key, value)
      @configurators[key] = value
    end

    # Configurator class for given key
    #
    # === Parameters
    # key(String):: Configurator for given key
    #
    # === Return
    # cfg_class(Constant):: Configurator class if there is one
    # nil:: Otherwise
    def [](key)
      @configurators[key]
    end

    # Iterate through all configurators
    #
    # === Block
    # Block should take one argument which is the configurator being iterated on
    #
    # === Return
    # true:: Always return true
    def each(&blk)
      @configurators.keys.map(&:to_s).sort.each { |k| blk.call(k, @configurators[k.to_sym]) }
      true
    end

    protected

    # Initialize configurators hash
    def initialize
      @configurators = Hash.new
    end

  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
rconf-0.9.18 lib/rconf/configurator_registry.rb
rconf-0.9.17 lib/rconf/configurator_registry.rb
rconf-0.9.12 lib/rconf/configurator_registry.rb
rconf-0.9.11 lib/rconf/configurator_registry.rb
rconf-0.9.10 lib/rconf/configurator_registry.rb
rconf-0.9.9 lib/rconf/configurator_registry.rb
rconf-0.9.8 lib/rconf/configurator_registry.rb
rconf-0.9.7 lib/rconf/configurator_registry.rb
rconf-0.9.6 lib/rconf/configurator_registry.rb
rconf-0.9.4 lib/rconf/configurator_registry.rb
rconf-0.8.30 lib/rconf/configurator_registry.rb
rconf-0.8.29 lib/rconf/configurator_registry.rb
rconf-0.8.21 lib/rconf/configurator_registry.rb
rconf-0.8.20 lib/rconf/configurator_registry.rb
rconf-0.8.19 lib/rconf/configurator_registry.rb
rconf-0.8.18 lib/rconf/configurator_registry.rb
rconf-0.8.17 lib/rconf/configurator_registry.rb
rconf-0.8.16 lib/rconf/configurator_registry.rb
rconf-0.8.15 lib/rconf/configurator_registry.rb
rconf-0.8.14 lib/rconf/configurator_registry.rb