Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get rid of ruby's warning: already initialized constant

Tags:

ruby

xml-rpc

I'm trying to redefine a gem's constant dynamically so I don't need to modify the gem itself.

require 'xmlrpc/client'

XMLRPC::Config.const_set("ENABLE_NIL_PARSER", true)

warning: already initialized constant ENABLE_NIL_PARSER

Is it possible to get rid of the warning?

like image 827
cfpete Avatar asked Dec 20 '22 16:12

cfpete


1 Answers

The easy way:

v, $VERBOSE = $VERBOSE, nil
# code goes here
$VERBOSE = v
like image 128
pguardiario Avatar answered Mar 08 '23 08:03

pguardiario