Reputation: 11336
is there any way to refactor this code?
def my_method
response = HTTParty.post 'http://www.url.com', {
body: {
param1: "value1",
param2: "value2"
}
}
response.message.include?("OK") ? true : false
end
I'd like to check if the response message includes okay but without needing to define the response as a variable. Is there any way I can retrieve the current method reply from the previous step in the method?
Upvotes: 1
Views: 90
Reputation: 1500
def my_method
HTTParty.post('http://www.url.com', {
body: {
param1: "value1",
param2: "value2"
}
}).message.include?("OK")
end
Upvotes: 1
Reputation: 121000
HTTParty.post('http://www.url.com', {
body: {
param1: "value1",
param2: "value2"
}
}).message.include?("OK")
Please note, that ? true : false
is also redundant.
Upvotes: 9