Sha256: aac4e13795172b566937750c70f12cbc3dd0c1974ee22b65e31c9bc2e0e7609a

Contents?: true

Size: 641 Bytes

Versions: 16

Compression:

Stored size: 641 Bytes

Contents

require 'natives/catalog/validator'

module Natives
  class Catalog
    class Merger
      def initialize(opts={})
        @validator = opts.fetch(:validator, Validator.new)
      end

      def merge_catalog!(master_hash, hash_to_merge)
        @validator.ensure_valid_catalog_groups(master_hash)
        @validator.ensure_valid_catalog_groups(hash_to_merge)

        hash_to_merge.each do |group_name, entries|
          if master_hash.key? group_name
            master_hash[group_name].merge! entries
          else
            master_hash[group_name] = entries
          end
        end

        master_hash
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
natives-0.6.2 lib/natives/catalog/merger.rb
natives-0.6.1 lib/natives/catalog/merger.rb
natives-0.6.0 lib/natives/catalog/merger.rb
natives-0.5.5 lib/natives/catalog/merger.rb
natives-0.5.4 lib/natives/catalog/merger.rb
natives-0.5.3 lib/natives/catalog/merger.rb
natives-0.5.2 lib/natives/catalog/merger.rb
natives-0.5.1 lib/natives/catalog/merger.rb
natives-0.5.0 lib/natives/catalog/merger.rb
natives-catalog-0.3.4 lib/natives/catalog/merger.rb
natives-catalog-0.3.3 lib/natives/catalog/merger.rb
natives-catalog-0.3.2 lib/natives/catalog/merger.rb
natives-catalog-0.3.1 lib/natives/catalog/merger.rb
natives-catalog-0.3.0 lib/natives/catalog/merger.rb
natives-catalog-0.2.1 lib/natives/catalog/merger.rb
natives-catalog-0.2.0 lib/natives/catalog/merger.rb