Ruby service objects call+run

Note last edited January 2022

The service objects I write in Ruby typically are called with #call, but the implementation lives in #run:

class AbstractService
  def call
    run
  end

  private

  def run
    raise "Not implemented"
  end
end

The advantage of this approach is that #call can be changed to support other use cases, like recording telemetry or logging.

This works well with Sorbet too.

Note last edited January 2022.