File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,9 @@ def self.for_exception(exception)
151151 Response [ 500 , Headers [ "content-type" => "text/plain" ] , [ "#{ exception . class } : #{ exception . message } " ] ]
152152 end
153153
154+ # Convert the response to a hash suitable for serialization.
155+ #
156+ # @returns [Hash] The response as a hash.
154157 def as_json ( ...)
155158 {
156159 version : @version ,
@@ -161,14 +164,23 @@ def as_json(...)
161164 }
162165 end
163166
167+ # Convert the response to JSON.
168+ #
169+ # @returns [String] The response as JSON.
164170 def to_json ( ...)
165171 as_json . to_json ( ...)
166172 end
167173
174+ # Summarise the response as a string.
175+ #
176+ # @returns [String] The response as a string.
168177 def to_s
169178 "#{ @status } #{ @version } "
170179 end
171180
181+ # Implicit conversion to an array.
182+ #
183+ # @returns [Array] The response as an array, e.g. `[status, headers, body]`.
172184 def to_ary
173185 return @status , @headers , @body
174186 end
You can’t perform that action at this time.
0 commit comments