Class: Rack::Stream::App
- Inherits:
-
Object
show all
- Defined in:
- lib/rack/stream/app.rb
Defined Under Namespace
Classes: StateConstraintError, UnsupportedServerError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(app, options = {}) ⇒ App
Returns a new instance of App.
18
19
20
21
22
|
# File 'lib/rack/stream/app.rb', line 18
def initialize(app, options={})
@app = app
@state = :new
@callbacks = Hash.new {|h,k| h[k] = []}
end
|
Instance Attribute Details
Returns the value of attribute headers.
16
17
18
|
# File 'lib/rack/stream/app.rb', line 16
def
@headers
end
|
#state ⇒ Object
The state of the connection
:new
:open
:closed
11
12
13
|
# File 'lib/rack/stream/app.rb', line 11
def state
@state
end
|
#status ⇒ Object
Returns the value of attribute status.
16
17
18
|
# File 'lib/rack/stream/app.rb', line 16
def status
@status
end
|
Instance Method Details
#call(env) ⇒ Object
24
25
26
27
|
# File 'lib/rack/stream/app.rb', line 24
def call(env)
EM.next_tick {open!(env)}
ASYNC_RESPONSE
end
|
#chunk(*chunks) ⇒ Object
Also known as:
<<
39
40
41
42
43
44
|
# File 'lib/rack/stream/app.rb', line 39
def chunk(*chunks)
require_state :new, :open
run_callbacks(:chunk, chunks) {|mutated_chunks|
@handler.chunk(*mutated_chunks)
}
end
|
#close(flush = true) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/rack/stream/app.rb', line 47
def close(flush = true)
require_state :open
EM.next_tick {
run_callbacks(:close) {
@state = :closed
@handler.close!(flush)
}
}
end
|
#closed? ⇒ Boolean
67
|
# File 'lib/rack/stream/app.rb', line 67
def closed?; @state == :closed end
|
#errored? ⇒ Boolean
68
|
# File 'lib/rack/stream/app.rb', line 68
def errored?; @state == :errored end
|
#new? ⇒ Boolean
65
|
# File 'lib/rack/stream/app.rb', line 65
def new?; @state == :new end
|
#open? ⇒ Boolean
66
|
# File 'lib/rack/stream/app.rb', line 66
def open?; @state == :open end
|
#stream_transport ⇒ String
Returns name of the handler for this request.
61
62
63
|
# File 'lib/rack/stream/app.rb', line 61
def stream_transport
@handler and @handler.class.name.split('::').last
end
|