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 |
Constant Summary
-
BODY_METHODS =
# File 'actionpack/lib/action_dispatch/http/response.rb', line 108{ to_ary: true }
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)
- #respond_to?(method, include_private = false) ⇒ Boolean
- #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 161
def closed? @closed end
Instance Method Details
#<<(string)
Alias for #write.
# File 'actionpack/lib/action_dispatch/http/response.rb', line 141
alias_method :<<, :write
#abort
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 153
def abort end
#body
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 126
def body @str_body ||= begin buf = +"" each { |chunk| buf << chunk } buf end end
#close
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 156
def close @response.commit! @closed = true end
#each(&block)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 143
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 166
def each_chunk(&block) @buf.each(&block) end
#respond_to?(method, include_private = false) ⇒ Boolean
# File 'actionpack/lib/action_dispatch/http/response.rb', line 110
def respond_to?(method, include_private = false) if BODY_METHODS.key?(method) @buf.respond_to?(method) else super end end
#to_ary
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/response.rb', line 118
def to_ary if @str_body [body] else @buf = @buf.to_ary end end