Sha256: c5f2fdfcfe31a1f8993fdeb81715cc85e0f3ef3c7069b26fe8489c1ce6b9ed98
Contents?: true
Size: 826 Bytes
Versions: 4
Compression:
Stored size: 826 Bytes
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. require_relative 'wrapper' module Protocol module HTTP module Body # Invokes a callback once the body has completed, either successfully or due to an error. class Completable < Wrapper def self.wrap(message, &block) if body = message&.body and !body.empty? message.body = self.new(message.body, block) else yield end end def initialize(body, callback) super(body) @callback = callback end def rewindable? false end def rewind false end def close(error = nil) super.tap do if @callback @callback.call(error) @callback = nil end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems