Skip to content

Commit

Permalink
Remove usage of ActiveSupport's #present? method (fixes #253)
Browse files Browse the repository at this point in the history
Replaces it with #empty?
  • Loading branch information
tarcieri committed Sep 7, 2015
1 parent eb80528 commit ae53708
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/http/request/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def send_request_body
private

def write(data)
while data.present?
until data.empty?
length = @socket.write(data)
if data.length > length
data = data[length..-1]
Expand Down

3 comments on commit ae53708

@ixti
Copy link
Member

@ixti ixti commented on ae53708 Sep 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while data.present? and until data.empty? are not the same.
present? exists on Nil and String. So, the more correct version would be:

while data && !data.empty?

@tarcieri
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that #present? is semantically different, although that's irrelevant here as data will never be nil.

Also it seems the main escape clause is the break a few lines down...

@ixti
Copy link
Member

@ixti ixti commented on ae53708 Sep 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Sorry. Indeed. Next time will try to read full code before making any judgements :D
Thanks for clearing this out!

Please sign in to comment.