Custom map on `Array`
My implementation is very similar to yours, with only a few small tweaks:

module Enumerable
  def map_with(accessor, default_value: nil)
    map { |e| e.respond_to?(accessor) ? e.send(accessor) : default_value }
  end
end



Use Enumerable, not Array, so that the method can be applied to other objects such as instances of Hash, Set, etc.
Use respond_to? rather than a type-check against nil, for better duck-typing robustness.
Use a named parameter, for improved code clarity.