rails / spring

Rails application preloader
MIT License
2.81k stars 341 forks source link

Fix raise signature for Ruby < 3.2 #698

Closed esposito closed 1 year ago

esposito commented 1 year ago

In Ruby versions older than 3.2, objects that respond to #to_hash are always used to extract keyword arguments from when **kwargs is present in a method signature. It causes these objects to be passed in as a hash to the raise method instead of an object.

Code like raise CustomError, object_implementing_to_hash, which relies on object_implementing_to_hash to be an object, no longer works.

In this commit we ensure above code keeps working until keyword arguments are fixed in Ruby 3.2.