class Roda::RodaPlugins::SinatraHelpers::DelayedBody
write to it.
of using Roda’s default body array and response.write to
Class used when the response body is set explicitly, instead
def each
returned by calling each on the body.
If the body is a String, yield it, otherwise yield each string
def each v = value if v.is_a?(String) yield v else v.each{|s| yield s} end end
def empty?
never empty.
Assume that if the body has been set directly that it is
def empty? false end
def initialize(&block)
called until the body is needed.
Save the block that will return the body, it won’t be
def initialize(&block) @block = block end
def join
Return the body as a single string, mostly useful during testing.
def join a = [] each{|s| a << s} a.join end
def length
Calculate the length for the body.
def length length = 0 each{|s| length += s.bytesize} length end
def value
be called multiple times.
Cache the body returned by the block. This way the block won’t
def value @value ||= @block.call end