Class: Natives::Catalog::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/natives/catalog/validator.rb

Instance Method Summary collapse

Instance Method Details

#ensure_valid_catalog_groups(hash) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/natives/catalog/validator.rb', line 4

def ensure_valid_catalog_groups(hash)
  unless hash.kind_of? Hash
    raise ArgumentError, 'catalog should be a Hash'
  end

  invalid_groups = hash.select {|key, value| !value.kind_of?(Hash) }
  unless invalid_groups.empty?
    group_names = invalid_groups.keys
    raise ArgumentError,
      "The following catalog group(s) should be a Hash: #{group_names.join(', ')}"
  end
end