Sha256: 8811b95dd29e282bfea97d7e2f8e93933f2250a616567fc2a256143b9bcbd5d0
Contents?: true
Size: 576 Bytes
Versions: 2
Compression:
Stored size: 576 Bytes
Contents
# frozen_string_literal: true module Pcli module Util class Hash def self.require(hash, key, message = nil) message ||= "The key \"#{key}\" must exist in the hash #{hash}" raise message unless hash[key] hash[key] end def self.require_presence(hash, key, message = nil) message ||= "The key \"#{key}\" must be present in the hash #{hash}" raise message unless hash.key?(key) hash[key] end def self.has_keys?(hash, *keys) keys.all? { |k| hash.key?(k) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pcli-0.1.1 | lib/pcli/util/hash.rb |
pcli-0.1.0 | lib/pcli/util/hash.rb |