Class: Rack::Stream::Handlers::AbstractHandler
- Inherits:
-
Object
- Object
- Rack::Stream::Handlers::AbstractHandler
- Defined in:
- lib/rack/stream/handlers.rb
Overview
A handler instance is responsible for managing the opening, streaming, and closing for a particular protocol.
All handlers should inherit from AbstractHandler
. Subclasses that
inherit later have higher precedence than later subclassed handlers.
Direct Known Subclasses
Class Attribute Summary collapse
-
.handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Class Method Summary collapse
-
.accepts?(app) ⇒ Boolean
Whether this handler knows how to handle a given request.
Instance Method Summary collapse
-
#chunk(*chunks) ⇒ Object
Enqueue content to be streamed at a later time.
-
#close ⇒ Object
Implement
#close
for cleanup#close
is called before the DeferrableBody is succeeded. -
#initialize(app) ⇒ AbstractHandler
constructor
A new instance of AbstractHandler.
-
#open ⇒ Object
Implement
#open
to initiate a connection.
Constructor Details
#initialize(app) ⇒ AbstractHandler
Returns a new instance of AbstractHandler.
35 36 37 38 |
# File 'lib/rack/stream/handlers.rb', line 35 def initialize(app) @app = app @body = DeferrableBody.new end |
Class Attribute Details
.handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
20 21 22 |
# File 'lib/rack/stream/handlers.rb', line 20 def handlers @handlers end |
Class Method Details
.accepts?(app) ⇒ Boolean
Whether this handler knows how to handle a given request
29 30 31 |
# File 'lib/rack/stream/handlers.rb', line 29 def accepts?(app) raise NotImplementedError end |
Instance Method Details
#chunk(*chunks) ⇒ Object
Enqueue content to be streamed at a later time.
Optionally override this method if you need to control the content at a protocol level.
44 45 46 |
# File 'lib/rack/stream/handlers.rb', line 44 def chunk(*chunks) @body.chunk(*chunks) end |
#close ⇒ Object
Implement #close
for cleanup
#close
is called before the DeferrableBody is succeeded.
67 68 69 |
# File 'lib/rack/stream/handlers.rb', line 67 def close # do nothing end |
#open ⇒ Object
Implement #open
to initiate a connection
55 56 57 |
# File 'lib/rack/stream/handlers.rb', line 55 def open raise NotImplementedError end |