Class: Protocol::HTTP::Body::Cacheable
- Inherits:
-
Rewindable
- Object
- Readable
- Wrapper
- Rewindable
- Protocol::HTTP::Body::Cacheable
- Defined in:
- lib/protocol/http/body/cacheable.rb
Instance Attribute Summary
Attributes inherited from Wrapper
Class Method Summary collapse
Methods inherited from Rewindable
#buffered, #initialize, #inspect, #read, #rewind
Methods inherited from Wrapper
#close, #empty?, #finish, #initialize, #inspect, #length, #read
Methods inherited from Readable
#close, #each, #empty?, #finish, #join, #length, #read
Constructor Details
This class inherits a constructor from Protocol::HTTP::Body::Rewindable
Class Method Details
.wrap(message, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/protocol/http/body/cacheable.rb', line 30 def self.wrap(, &block) if body = .body # Create a rewindable body wrapping the message body: rewindable = Rewindable.new(body) # Set the message body to the rewindable body: .body = rewindable # Wrap the message with the callback: Streamable.wrap() do |error| unless error yield , rewindable.buffered end end else yield , nil end end |