You can invoke OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
before to unset the constant, set it as you need it, and restore it to its original value afterwards. Here is example code from a gist:
prev_setting = OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
OpenSSL::SSL.const_set(:VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE)
# HTTP requests with DISABLED certificate verification go here.
OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
OpenSSL::SSL.const_set(:VERIFY_PEER, prev_setting)
Source and attribution: The solution comes from a comment by @sameers on Stack Overflow. Licenced under CC-BY-SA 4.0 as per the Stack Overflow user contribution licensing policy. The gist is assumed to be part of that as the author indicated their original intent of publishing it in a Stack Overflow comment.