Sha256: ea789992d5b26263931d665c686c4180b7ee8e07c138b4e88f4928246a34fe28

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 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]
      end

      def []= label, value
        raise "Must be a label" if !label.kind_of_label?
        registered[label] = 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

6 entries across 6 versions & 1 rubygems

Version Path
cantango-0.8.7 lib/cantango/configuration/hash_registry.rb
cantango-0.8.6.2 lib/cantango/configuration/hash_registry.rb
cantango-0.8.6.1 lib/cantango/configuration/hash_registry.rb
cantango-0.8.6 lib/cantango/configuration/hash_registry.rb
cantango-0.8.5.1 lib/cantango/configuration/hash_registry.rb
cantango-0.8.0 lib/cantango/configuration/hash_registry.rb