Sha256: f7fc0a1f6aa658c6847bebbee3e40f03ec3f4c8621a589e167e6ec950ed37eea

Contents?: true

Size: 1.09 KB

Versions: 16

Compression:

Stored size: 1.09 KB

Contents

require 'singleton'
require 'sugar-high/kind_of'

module CanTango
  class Configuration
    class HashRegistry < Registry

      def types= *types
        raise "This is a Hash registry!"
      end

      def types
        [Hash]
      end

      def clean!
        registered = Hashie::Mash.new
      end

      def clear!
        clean!
      end

      def default!
        @registered = default
      end

      def << hash
        raise "Must be a hash" if !hash.is_a? Hash
        registered.merge! hash
      end

      def [] label
        raise "Must be a label" if !label.kind_of_label?
        registered[label.to_s]
      end

      def []= label, value
        raise "Must be a label" if !label.kind_of_label?
        registered[label.to_s] = value
      end

      def register hash
        raise "Must be a hash" if !hash.is_a? Hash
        registered.merge! hash
      end

      def registered
        @registered ||= default
      end

      def default
        @default ||= Hashie::Mash.new
      end

      def default= hash
        @default = Hashie::Mash.new hash
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/cantango/configuration/hash_registry.rb
cantango-0.9.4.6 lib/cantango/configuration/hash_registry.rb
cantango-0.9.4.5 lib/cantango/configuration/hash_registry.rb
cantango-0.9.4.3 lib/cantango/configuration/hash_registry.rb
cantango-0.9.4.2 lib/cantango/configuration/hash_registry.rb
cantango-0.9.4.1 lib/cantango/configuration/hash_registry.rb
cantango-0.9.4 lib/cantango/configuration/hash_registry.rb
cantango-0.9.3.2 lib/cantango/configuration/hash_registry.rb
cantango-0.8.9.5 lib/cantango/configuration/hash_registry.rb
cantango-0.8.9.4 lib/cantango/configuration/hash_registry.rb
cantango-0.8.9.3 lib/cantango/configuration/hash_registry.rb
cantango-0.8.9.2 lib/cantango/configuration/hash_registry.rb
cantango-0.8.9.1 lib/cantango/configuration/hash_registry.rb
cantango-0.8.9 lib/cantango/configuration/hash_registry.rb
cantango-0.8.8.1 lib/cantango/configuration/hash_registry.rb
cantango-0.8.8 lib/cantango/configuration/hash_registry.rb