Sha256: 6b54a70bbd1281d2b0d9cde3e681749b6154a504ad1e0fa17bb10f37691f7d83
Contents?: true
Size: 826 Bytes
Versions: 5
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
5 entries across 5 versions & 1 rubygems