I imagine the premise of this post is basically to just kick off an exploration into TruffleRuby, which is cool! And an interesting read re: the benchmarking and performance of the implementation.
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
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.