Class: Supabase::Postgrest::SingleAPIResponse
- Inherits:
-
APIResponse
- Object
- APIResponse
- Supabase::Postgrest::SingleAPIResponse
- Defined in:
- lib/supabase/postgrest/request_builder.rb
Overview
Same as APIResponse but the wire was scalar (single-row endpoints).
Instance Attribute Summary
Attributes inherited from APIResponse
Class Method Summary collapse
Methods inherited from APIResponse
Constructor Details
This class inherits a constructor from Supabase::Postgrest::APIResponse
Class Method Details
.from_response(response, request_prefer: nil) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/supabase/postgrest/request_builder.rb', line 155 def self.from_response(response, request_prefer: nil) count = APIResponse.extract_count(response, request_prefer) data = begin body = response.body body && !body.empty? ? JSON.parse(body) : [] rescue JSON::ParserError body.to_s.empty? ? [] : body.to_s end new(data: data, count: count) end |