Skip to content

Commit 2710480

Browse files
chore(internal): allow streams to also be unwrapped on a per-row basis
1 parent 64a0591 commit 2710480

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/onebusaway_sdk/internal/transport/base_client.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ def request(req)
481481
self.class.validate!(req)
482482
model = req.fetch(:model) { OnebusawaySDK::Internal::Type::Unknown }
483483
opts = req[:options].to_h
484+
unwrap = req[:unwrap]
484485
OnebusawaySDK::RequestOptions.validate!(opts)
485486
request = build_request(req.except(:options), opts)
486487
url = request.fetch(:url)
@@ -497,11 +498,18 @@ def request(req)
497498
decoded = OnebusawaySDK::Internal::Util.decode_content(response, stream: stream)
498499
case req
499500
in {stream: Class => st}
500-
st.new(model: model, url: url, status: status, response: response, stream: decoded)
501+
st.new(
502+
model: model,
503+
url: url,
504+
status: status,
505+
response: response,
506+
unwrap: unwrap,
507+
stream: decoded
508+
)
501509
in {page: Class => page}
502510
page.new(client: self, req: req, headers: response, page_data: decoded)
503511
else
504-
unwrapped = OnebusawaySDK::Internal::Util.dig(decoded, req[:unwrap])
512+
unwrapped = OnebusawaySDK::Internal::Util.dig(decoded, unwrap)
505513
OnebusawaySDK::Internal::Type::Converter.coerce(model, unwrapped)
506514
end
507515
end

0 commit comments

Comments
 (0)