Class: Protein::Payload::Response
- Inherits:
-
Object
- Object
- Protein::Payload::Response
- Defined in:
- lib/protein/payload.rb
Class Method Summary collapse
Class Method Details
.decode(payload) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/protein/payload.rb', line 36 def decode(payload) hash = JSON.parse(payload) response_buf_b64 = hash["response_buf_b64"] response_buf = response_buf_b64 && Base64.strict_decode64(response_buf_b64) errors = hash["errors"] errors = errors && decode_errors(errors) [response_buf, errors] end |
.encode(response_buf, errors) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/protein/payload.rb', line 29 def encode(response_buf, errors) JSON.dump({ "response_buf_b64" => response_buf && Base64.strict_encode64(response_buf), "errors" => encode_errors(errors) }) end |