Class: Apiwork::Response
- Inherits:
-
Object
- Object
- Apiwork::Response
- Defined in:
- lib/apiwork/response.rb
Overview
Immutable value object representing a response.
Encapsulates body parameters. Transformations return new instances, preserving immutability.
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
The body for this response.
Instance Method Summary collapse
-
#initialize(body:) ⇒ Response
constructor
Creates a new response context.
-
#transform {|Hash| ... } ⇒ Response
Transforms the body parameters.
-
#transform_body {|Hash| ... } ⇒ Response
Transforms the body parameters.
Constructor Details
#initialize(body:) ⇒ Response
Creates a new response context.
28 29 30 |
# File 'lib/apiwork/response.rb', line 28 def initialize(body:) @body = body end |
Instance Attribute Details
#body ⇒ Hash (readonly)
The body for this response.
21 22 23 |
# File 'lib/apiwork/response.rb', line 21 def body @body end |
Instance Method Details
#transform {|Hash| ... } ⇒ Response
Transforms the body parameters.
40 41 42 |
# File 'lib/apiwork/response.rb', line 40 def transform self.class.new(body: yield(body)) end |
#transform_body {|Hash| ... } ⇒ Response
Transforms the body parameters.
52 53 54 |
# File 'lib/apiwork/response.rb', line 52 def transform_body self.class.new(body: yield(body)) end |