Class: ActionDispatch::Response::Buffer
Do not use. This class is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/http/response.rb |
Class Method Summary
- .new(response, buf) ⇒ Buffer constructor
Instance Attribute Summary
- #closed? ⇒ Boolean readonly
Instance Method Summary
-
#<<(string)
Alias for #write.
- #abort
- #body
- #close
- #each(&block)
- #to_ary
- #write(string) (also: #<<)
- #each_chunk(&block) private
Constructor Details
.new(response, buf) ⇒ Buffer
# File 'actionpack/lib/action_dispatch/http/response.rb', line 101
def initialize(response, buf) @response = response @buf = buf @closed = false @str_body = nil end
Instance Attribute Details
#closed? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/http/response.rb', line 149
def closed? @closed end
Instance Method Details
#<<(string)
Alias for #write.
# File 'actionpack/lib/action_dispatch/http/response.rb', line 129
alias_method :<<, :write
#abort
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 141
def abort end
#body
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 114
def body @str_body ||= begin buf = +"" each { |chunk| buf << chunk } buf end end
#close
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 144
def close @response.commit! @closed = true end
#each(&block)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 131
def each(&block) if @str_body return enum_for(:each) unless block_given? yield @str_body else each_chunk(&block) end end
#each_chunk(&block) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 154
def each_chunk(&block) @buf.each(&block) end
#to_ary
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 108
def to_ary @buf.respond_to?(:to_ary) ? @buf.to_ary : @buf.each end