Class: Webmachine::Streaming::FiberEncoder Private

Inherits:
Encoder
  • Object
show all
Includes:
Enumerable
Defined in:
lib/webmachine/streaming/fiber_encoder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Implements a streaming encoder for Fibers with the same API as the EnumerableEncoder. This will resume the Fiber until it terminates or returns a falsey value.

Instance Attribute Summary

Attributes inherited from Encoder

#body, #charsetter, #encoder, #resource

Instance Method Summary collapse

Methods inherited from Encoder

#initialize

Constructor Details

This class inherits a constructor from Webmachine::Streaming::Encoder

Instance Method Details

#eachObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Iterates over the body by yielding to the fiber.



14
15
16
17
18
# File 'lib/webmachine/streaming/fiber_encoder.rb', line 14

def each
  while body.alive? && chunk = body.resume
    yield resource.send(encoder, resource.send(charsetter, chunk.to_s))
  end
end