Skip to content

Remove AbstractResponse#to_i, which is too unexpected, considering:#103

Merged
ab merged 1 commit intorest-client:masterfrom
godfat:no-to_i
Mar 14, 2015
Merged

Remove AbstractResponse#to_i, which is too unexpected, considering:#103
ab merged 1 commit intorest-client:masterfrom
godfat:no-to_i

Conversation

@godfat
Copy link
Contributor

@godfat godfat commented Nov 29, 2011

require 'webmock'
require 'rest-client'
WebMock::API.stub_request(:get, 'http://host/').to_return(:body => '123')

RestClient.get('http://host/')        # "123"
RestClient.get('http://host/').to_s   # "123"
RestClient.get('http://host/').to_str # "123"
RestClient.get('http://host/').class  # String

RestClient.get('http://host/').to_i         # 200
RestClient.get('http://host/').to_s.to_i    # 200
RestClient.get('http://host/').to_str.to_i  # 200
String(RestClient.get('http://host/')).to_i # 200

RestClient.get('http://host/').dup.to_i         # 123
String.new(RestClient.get('http://host/')).to_i # 123
"#{RestClient.get('http://host/')}".to_i        # 123

RestClient.get('http://host/').clone.to_i       # 200

require 'webmock'
require 'rest-client'
WebMock::API.stub_request(:get, 'http://host/').to_return(:body => '123')

RestClient.get('http://host/')        # "123"
RestClient.get('http://host/').to_s   # "123"
RestClient.get('http://host/').to_str # "123"
RestClient.get('http://host/').class  # String

RestClient.get('http://host/').to_i         # 200
RestClient.get('http://host/').to_s.to_i    # 200
RestClient.get('http://host/').to_str.to_i  # 200
String(RestClient.get('http://host/')).to_i # 200

RestClient.get('http://host/').dup.to_i         # 123
String.new(RestClient.get('http://host/')).to_i # 123
"#{RestClient.get('http://host/')}".to_i        # 123

RestClient.get('http://host/').clone.to_i       # 200
@ayamomiji
Copy link

+1 for this, i just wasted too much time on this...

@L2G
Copy link
Member

L2G commented Mar 9, 2013

(For reference only: This is one of many patches included in #106.)

@dinatih
Copy link

dinatih commented Feb 25, 2014

+1 please

@ab
Copy link
Member

ab commented Mar 28, 2014

Ugh, this behavior is painful. I'm wary of removing it outright though, since it's been around for so long, and people might be relying on it.

@ab ab added the bug label Mar 28, 2014
@ab ab merged commit b5d5a85 into rest-client:master Mar 14, 2015
@ab ab added this to the 2.0.0 milestone Mar 14, 2015
@ab ab self-assigned this Mar 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants