News for hackers. Stuff that matters.
Re:"Useless Ruby sugar": Argument forwarding by bradly on Friday November 24, 2023 @02:44PM (#38407444)
Here is common use case I use for this in my Rails apps:

This is the most common way I use it:

    class ApplicationService
      def call
        raise NotImplementedError
      end
    
      def self.call(...)
        new(...).call
      end
    end
    
    class MyService < ApplicationService
      def call(service_specific_arg: 123)
        #...
      end
    end
Re:"Useless Ruby sugar": Argument forwarding by viralpraxis on Friday November 24, 2023 @04:39PM (#38408670)
I’ve been using the same structure for years :)

But I prefer to replace ‘raise NotImplementedError’ with ´raise “Not Implemeneted”’ because that exception has different semantics (method unavailability on the current platform)

Re:"Useless Ruby sugar": Argument forwarding by prognostikos on Saturday November 25, 2023 @02:54AM (#38412025)
I also avoid `NotImplementedError` as it inherits from `Error` instead of `StandardError`. This can bring down services like job queue processors that rescue `StandardError`.
Re:"Useless Ruby sugar": Argument forwarding by still_grokking on Saturday November 25, 2023 @03:48AM (#38412216)
What is this code good for?

I can understand what it does but I don't get the intend behind that. (I'm not a Ruby programmer, so maybe I miss something "obvious")