A shame that refinements don't really get much love, because the third option (in between monkey patching and extending the core library), is to use one of those.
module DigWithFallback
refine Hash do
def dig_fetch(*keys)
# ... impl
end
end
end
class SomeService
using DigWithFallback
def call(params)
params.dig_fetch(:some, :key) { IdentityObject.new }
end
end