0

Looking for an elegant way to include a method argument if a statement is true. In this case it is a rest-client call, the argument is verify_ssl: FALSE. Below is the code with my last attempt I want to insert verify_ssl if @ignore_cert is TRUE. This is part of a larger class I have created. Thanks in advance!

def get_tenant_uid
  JSON.parse(RestClient::Request.execute(method: :get,url: "#{base_url}/tenant",
    headers: {:'X-SDS-AUTH-TOKEN' => @auth_token,
      accept: :json
    },
    verify_ssl: FALSE if @ignore_cert
  ))
end
nctiggy
  • 73
  • 9
  • 1
    How about `verify_ssl: !@ignore_cert`? – Mischa Aug 19 '14 at 16:34
  • no dice, but this did lead to the obvious answer...doh! changed setting from ignore_cert to verify_cert in the config file. Now it is verify_ssl: @verify_cert. Thanks for the mental push! – nctiggy Aug 19 '14 at 16:40
  • I don't understand why `verify_ssl: !@ignore_cert` wouldn't work, but glad to hear you got it working by renaming the variable. – Mischa Aug 19 '14 at 16:43
  • Got it working by converting to a boolean, twas a string before. !@ignore_cert would have worked. Thanks again! – nctiggy Aug 19 '14 at 16:54

0 Answers0