Sha256: 5b9731c9c4cd7288d4bb57611418246b2ee01f142fae3e58aba9c5a5b598404b

Contents?: true

Size: 861 Bytes

Versions: 13

Compression:

Stored size: 861 Bytes

Contents

require 'ns-options/namespace'

module NsOptions
  class Namespaces

    def initialize
      @hash = Hash.new
    end

    # for hash with indifferent access behavior
    def [](name);         @hash[name.to_s];         end
    def []=(name, value); @hash[name.to_s] = value; end

    def keys(*args, &block);   @hash.keys(*args, &block);   end
    def each(*args, &block);   @hash.each(*args, &block);   end
    def empty?(*args, &block); @hash.empty?(*args, &block); end

    def add(name, ns); self[name] = ns;         end
    def rm(name);      @hash.delete(name.to_s); end
    def get(name);     self[name];              end

    def required_set?
      are_all_these_namespaces_set? @hash.values
    end

    private

    def are_all_these_namespaces_set?(namespaces)
      namespaces.inject(true) {|bool, ns| bool && ns.required_set?}
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ns-options-1.1.6 lib/ns-options/namespaces.rb
ns-options-1.1.5 lib/ns-options/namespaces.rb
ns-options-1.1.4 lib/ns-options/namespaces.rb
ns-options-1.1.3 lib/ns-options/namespaces.rb
ns-options-1.1.2 lib/ns-options/namespaces.rb
ns-options-1.1.1 lib/ns-options/namespaces.rb
ns-options-1.1.0 lib/ns-options/namespaces.rb
ns-options-1.0.1 lib/ns-options/namespaces.rb
ns-options-1.0.0 lib/ns-options/namespaces.rb
ns-options-1.0.0.rc4 lib/ns-options/namespaces.rb
ns-options-1.0.0.rc3 lib/ns-options/namespaces.rb
ns-options-1.0.0.rc2 lib/ns-options/namespaces.rb
ns-options-1.0.0.rc1 lib/ns-options/namespaces.rb