module Tins::StringNamedPlaceholders
def named_placeholders_assign(hash, default: nil)
-
(Hash)
- A new hash containing the assigned values for each named
Parameters:
-
default
(Object, Proc
) -- The default value to use for placeholders not present in the hash. -
hash
(Hash
) -- A hash mapping placeholder names to their corresponding values.
def named_placeholders_assign(hash, default: nil) hash = hash.transform_keys(&:to_sym) named_placeholders.each_with_object({}) do |placeholder, h| h[placeholder] = hash[placeholder] || (default.is_a?(Proc) ? default.(placeholder) : default) end end