Module: Kind::AssertHash::Keys
- Defined in:
- lib/kind/__lib__/assert_hash.rb
Class Method Summary collapse
Class Method Details
.require_all(keys, hash) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kind/__lib__/assert_hash.rb', line 6 def self.require_all(keys, hash) expected_keys = keys - hash.keys unless expected_keys.empty? raise KeyError.new("#{hash.inspect} expected to have these keys: #{expected_keys}") end unexpected_keys = hash.keys - keys unless unexpected_keys.empty? raise KeyError.new("#{hash.inspect} expected to NOT have these keys: #{unexpected_keys}") end hash end |