Class: ActionController::Live::Buffer

Inherits:
ActionDispatch::Response::Buffer show all
Defined in:
lib/action_controller/metal/live.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from ActionDispatch::Response::Buffer

#closed?

Constructor Details

#initialize(response) ⇒ Buffer

Returns a new instance of Buffer.



36
37
38
39
# File 'lib/action_controller/metal/live.rb', line 36

def initialize(response)
  @error_callback = nil
  super(response, SizedQueue.new(10))
end

Instance Method Details

#call_on_errorObject



65
66
67
# File 'lib/action_controller/metal/live.rb', line 65

def call_on_error
  @error_callback.call
end

#closeObject



56
57
58
59
# File 'lib/action_controller/metal/live.rb', line 56

def close
  super
  @buf.push nil
end

#eachObject



50
51
52
53
54
# File 'lib/action_controller/metal/live.rb', line 50

def each
  while str = @buf.pop
    yield str
  end
end

#on_error(&block) ⇒ Object



61
62
63
# File 'lib/action_controller/metal/live.rb', line 61

def on_error(&block)
  @error_callback = block
end

#write(string) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/action_controller/metal/live.rb', line 41

def write(string)
  unless @response.committed?
    @response.headers["Cache-Control"] = "no-cache"
    @response.headers.delete "Content-Length"
  end

  super
end