Responsible::Response
Wrapper object for lifted responses. Provides extensions need for defining locally scoped error behaviors and parse tools for extraction of returned data.
Constructors
Creates a new Response by wrapping a supported response type. response
must by a type that includes ResponsibleInterface. This can be inserted
manually, or by using the Responsible.support macro.
Instance methods
Parses the contents of this response to the type x.
If x is nilable, a parser error will result in nil being returned,
otherwise a Responsible::Error will be raised if parsing is not possible.
Reads the contents of the body into the specified type x.
If the response cannot be parsed, the block will be yielded to to provide an alternative parser.
T.from_json must exist and be capable of deserializing a JSON string.
This works out-of-the-box for most types where attributes map directly. The
JSON::Serializable module provides tools for more complex parsing.
Parses the contents of this response to the type x, or raises an
Responsible::Error if this is not possible.
Parses the contents of this response to the type x, or nil if this is not possible.