Response
Immutable value object representing a response.
Encapsulates body parameters. Transformations return new instances, preserving immutability.
Example: Creating a response
ruby
response = Response.new(body: { id: 1, title: "Hello" })
response.body # => { id: 1, title: "Hello" }Example: Transforming keys
ruby
response.transform { |data| camelize(data) }Instance Methods
#body
#body
The body for this response.
Returns
Hash
#initialize
#initialize(body:)
Creates a new response context.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
body | Hash | The body parameters. |
Returns
Response — a new instance of Response
#transform
#transform
Transforms the body parameters.
Returns
Example
ruby
response.transform { |data| camelize(data) }#transform_body
#transform_body
Transforms the body parameters.
Returns
Example
ruby
response.transform_body { |data| camelize(data) }