Sha256: 022be2467ba5f72a01c8915bca3500c740d14aaa7907adaa08f212140581db3b

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

# Copyright (C) 2011-2012 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

22 entries across 22 versions & 1 rubygems

Version Path
rconf-1.0.13 lib/rconf/configurator_registry.rb
rconf-1.0.12 lib/rconf/configurator_registry.rb
rconf-1.0.11 lib/rconf/configurator_registry.rb
rconf-1.0.10 lib/rconf/configurator_registry.rb
rconf-1.0.9 lib/rconf/configurator_registry.rb
rconf-1.0.8 lib/rconf/configurator_registry.rb
rconf-1.0.7 lib/rconf/configurator_registry.rb
rconf-1.0.6 lib/rconf/configurator_registry.rb
rconf-1.0.5 lib/rconf/configurator_registry.rb
rconf-1.0.4 lib/rconf/configurator_registry.rb
rconf-1.0.3 lib/rconf/configurator_registry.rb
rconf-1.0.1 lib/rconf/configurator_registry.rb
rconf-1.0.0 lib/rconf/configurator_registry.rb
rconf-0.10.1 lib/rconf/configurator_registry.rb
rconf-0.10.0 lib/rconf/configurator_registry.rb
rconf-0.9.25 lib/rconf/configurator_registry.rb
rconf-0.9.24 lib/rconf/configurator_registry.rb
rconf-0.9.23 lib/rconf/configurator_registry.rb
rconf-0.9.22 lib/rconf/configurator_registry.rb
rconf-0.9.21 lib/rconf/configurator_registry.rb