Sha256: 1754de2bfce0492e708d87f549d980b719a012c9a75b4c64646420a3b88a9072
Contents?: true
Size: 503 Bytes
Versions: 8
Compression:
Stored size: 503 Bytes
Contents
# frozen_string_literal: true # Used to validate incoming parameter hash. class VerifyKeyInHash def self.call(hash, key) VerifyKeyInHash.new(hash, key).call end def call raise KeyError, no_key_message unless key_in_hash? end protected def initialize(hash, key) @hash = hash @key = key self end private attr_reader :hash, :key def key_in_hash? hash.key? key end def no_key_message "No key :#{key} in #{hash}!" end end # class VerifyKeyInHash
Version data entries
8 entries across 8 versions & 1 rubygems