module Mixlib::CLI::InheritMethods

def deep_dup(object)

contents will be iterated and cloned as well.
`object`. If the provided `object` is an enumerable type the
This method will return a "deep clone" of the provided
object:: Instance to clone
def deep_dup(object)
  cloned_object = object.respond_to?(:dup) ? object.dup : object
  if cloned_object.is_a?(Enumerable)
    if cloned_object.is_a?(Hash)
      new_hash = cloned_object.class.new
      cloned_object.each do |key, value|
        cloned_key = deep_dup(key)
        cloned_value = deep_dup(value)
        new_hash[cloned_key] = cloned_value
      end
      cloned_object.replace(new_hash)
    else
      cloned_object.map! do |shallow_instance|
        deep_dup(shallow_instance)
      end
    end
  end
  cloned_object
rescue TypeError
  # Symbol will happily provide a `#dup` method even though
  # attempts to clone it will result in an exception (atoms!).
  # So if we run into an issue of TypeErrors, just return the
  # original object as we gave our "best effort"
  object
end

def inherited(receiver)

def inherited(receiver)
  receiver.options = deep_dup(options)
  receiver.extend(Mixlib::CLI::InheritMethods)
end