class Webmachine::Adapters::LazyRequestBody

Wraps a request body so that it can be passed to {Request} while still lazily evaluating the body.

Public Class Methods

new(request) click to toggle source
# File lib/webmachine/adapters/lazy_request_body.rb, line 6
def initialize(request)
  @request = request
end

Public Instance Methods

each() { |chunk| ... } click to toggle source

Iterates over the body in chunks. If the body has previously been read, this method can be called again and get the same sequence of chunks. @yield [chunk] @yieldparam [String] chunk a chunk of the request body

# File lib/webmachine/adapters/lazy_request_body.rb, line 26
def each
  @request.body { |chunk| yield chunk }
end
empty?() click to toggle source

Converts the body to a String and checks if it is empty.

# File lib/webmachine/adapters/lazy_request_body.rb, line 17
def empty?
  to_s.empty?
end
to_s() click to toggle source

Converts the body to a String so you can work with the entire thing.

# File lib/webmachine/adapters/lazy_request_body.rb, line 12
def to_s
  @request.body
end