Skip to content

Commit 82f3377

Browse files
committed
Add output stream #<< as alias for #write.
1 parent adb0e57 commit 82f3377

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/protocol/http/body/stream.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ def write(buffer)
151151
end
152152
end
153153

154-
alias write_nonblock write
154+
def write_nonblock(buffer)
155+
write(buffer)
156+
end
157+
158+
def << (buffer)
159+
write(buffer)
160+
end
155161

156162
def flush
157163
end

spec/protocol/http/body/stream_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,16 @@
115115
expect(output.chunks).to be == ["Hello", "World"]
116116
end
117117
end
118-
118+
119+
describe '#<<' do
120+
it "should write to the output" do
121+
subject << "Hello"
122+
subject << "World"
123+
124+
expect(output.chunks).to be == ["Hello", "World"]
125+
end
126+
end
127+
119128
describe "#write_nonblock" do
120129
it "should write to the output" do
121130
subject.write_nonblock("Hello")

0 commit comments

Comments
 (0)