class ReeObject::AsJson

def recursively_convert(obj, acc, cache)

def recursively_convert(obj, acc, cache)
  ancestors = obj.class.ancestors
  if ancestors.intersection(BASIC_TYPES).size > 0
    obj
  elsif obj.is_a?(Array)
    convert_array(obj, acc, cache)
  elsif obj.is_a?(Hash)
    convert_hash(obj, acc, cache)
  elsif obj.respond_to?(:to_h)
    convert_hash(obj.to_h, acc, cache)
  else
    convert_object(obj, acc, cache)
  end
end