Class: ActionDispatch::Response::Buffer
- Inherits:
-
Object
- Object
- ActionDispatch::Response::Buffer
show all
- Defined in:
- lib/action_dispatch/http/response.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(response, buf) ⇒ Buffer
Returns a new instance of Buffer.
99
100
101
102
103
104
|
# File 'lib/action_dispatch/http/response.rb', line 99
def initialize(response, buf)
@response = response
@buf = buf
@closed = false
@str_body = nil
end
|
Instance Method Details
#abort ⇒ Object
137
138
|
# File 'lib/action_dispatch/http/response.rb', line 137
def abort
end
|
#body ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/action_dispatch/http/response.rb', line 110
def body
@str_body ||= begin
buf = +""
each { |chunk| buf << chunk }
buf
end
end
|
#close ⇒ Object
140
141
142
143
|
# File 'lib/action_dispatch/http/response.rb', line 140
def close
@response.commit!
@closed = true
end
|
#closed? ⇒ Boolean
145
146
147
|
# File 'lib/action_dispatch/http/response.rb', line 145
def closed?
@closed
end
|
#each(&block) ⇒ Object
127
128
129
130
131
132
133
134
135
|
# File 'lib/action_dispatch/http/response.rb', line 127
def each(&block)
if @str_body
return enum_for(:each) unless block_given?
yield @str_body
else
each_chunk(&block)
end
end
|
#to_ary ⇒ Object
106
107
108
|
# File 'lib/action_dispatch/http/response.rb', line 106
def to_ary
@buf.to_ary
end
|
#write(string) ⇒ Object
Also known as:
<<
118
119
120
121
122
123
124
|
# File 'lib/action_dispatch/http/response.rb', line 118
def write(string)
raise IOError, "closed stream" if closed?
@str_body = nil
@response.commit!
@buf.push string
end
|