class Hash def needs(*keys) keys.each { |key| self[key] ||= '' } end def keeps(*checks) delete_if do |key, value| checks.none? { |check| check === key } end end end