require "securerandom"

class ManualBuilder
  def initialize(dependencies)
    @slug_generator = dependencies.fetch(:slug_generator)
    @factory = dependencies.fetch(:factory)
  end

  def call(attrs)
    @attrs = attrs

    factory.call(defaults.merge(attrs))
  end

  private

  attr_reader :slug_generator, :factory, :attrs

  def defaults
    {
      id: SecureRandom.uuid,
      slug: slug,
      summary: "",
      body: "",
      state: "draft",
      organisation_slug: "",
      updated_at: "",
      originally_published_at: nil,
      use_originally_published_at_for_public_timestamp: true,
    }
  end

  def slug
    slug_generator.call(attrs.fetch(:title))
  end
end

require "securerandom"

class ManualBuilder
  def initialize(slug_generator:, factory:)
    @slug_generator = slug_generator
    @factory = factory
  end

  def call(attrs)
    @attrs = attrs

    factory.call(defaults.merge(attrs))
  end

  private

  attr_reader :slug_generator, :factory, :attrs

  def defaults
    {
      id: SecureRandom.uuid,
      slug: slug,
      summary: "",
      body: "",
      state: "draft",
      organisation_slug: "",
      updated_at: "",
      originally_published_at: nil,
      use_originally_published_at_for_public_timestamp: true,
    }
  end

  def slug
    slug_generator.call(attrs.fetch(:title))
  end
end

Use Ruby keyword args in ManualBuilder
Use Ruby keyword args in ManualBuilder

I think that using language features instead of custom code makes this
easier to understand.
