Say you have a base class Base which includes HTTParty, sets some default headers, and then a subclass which inherits from Base. If one of the subclasses overrides headers, they are overridden for all three classes.
AFAICT, this defeats the whole purpose of the magic in HTTParty::ModuleInheritableAttributes, and so I must assume it's a bug.
headers 'Accept' => 'application/json'
class Subclass < Base
headers 'Accept' => 'application/xml'
ruby-1.8.7-p330 :004 > pp Base.headers
# SHOULD HAVE stayed as json!!!
change the clone call at line 21 of module_inheritable_attributes.rb.rb (https://github.com/jnunemaker/httparty/blob/master/lib/httparty/module_inheritable_attributes.rb) to instead be a deep_clone, through one of the various strategies to achieve that result that are available.
change the merge! call at line 175 of httparty.rb (https://github.com/jnunemaker/httparty/blob/master/lib/httparty.rb) to NOT merge into the existing hash, but into a clone, like this:
default_options[:headers] = default_options[:headers].merge(h) # STOPS altering the original hash
Deep copy in the superclass merging to ensure no sharing of nested ha…