A small service builds a summary from request parameters for an internal report. Right now, the same response structure sometimes changes after a repeated call, and part of the fields look inconsistent with the passed arguments.
build_summary method must accept keyword arguments user:, route:, and optional meta: and details:.details is not passed, the response must contain an empty value for this field that does not affect subsequent calls.meta must appear in the result as a separate copy of the data, so changes to the response do not affect the original object.latest_summary method must return the last built result without recomputation.build_summary call with different arguments must not change a hash that was already obtained earlier.ReportBuilder.build_summary without details and save the result.meta field in the returned hash.build_summary again with different user and route values.meta.Input example:
builder = ReportBuilder.new
first = builder.build_summary(user: "ana", route: "/inbox", meta: { source: "api" })
first[:meta][:source] = "ui"
second = builder.build_summary(user: "ben", route: "/archive")
first[:details] remains an empty value and does not turn into data from the next call.first[:meta] does not share nested objects with the passed meta.second reflects only the arguments of the second call.builder.latest_summary returns exactly the latest result, not the modified first structure.ruby report_builder.rbUse line comments to explain the problem, its impact, the fix and how to test it.