def to_hash(object, use_alias = false)
      return object.map { |i| to_hash(i, use_alias) } if object.is_a?(Array)

      validate_class_kit(object.class)

      hash = {}

      attributes = @attribute_helper.get_attributes(object.class)
      attributes.each do |attribute|
        key = use_alias ? (attribute[:alias] || attribute[:name]) : attribute[:name]
        type = attribute[:type]
        value = object.public_send(attribute[:name])
        if value != nil
          hash[key] = if is_class_kit?(type)
                        to_hash(value, use_alias)
                      elsif type == Array
                        value.map do |i|
                          if is_class_kit?(i.class)
                            to_hash(i, use_alias)
                          else
                            i
                          end
                        end
                      else
                        value
                      end
        end
      end
      @hash_helper.indifferent!(hash)
      hash
    end
def to_hash(object, use_alias = false)
      return object.map { |i| to_hash(i, use_alias) } if object.is_a?(Array)

      validate_class_kit(object.class)

      hash = {}

      attributes = @attribute_helper.get_attributes(object.class)
      attributes.each do |attribute|
        key = use_alias ? (attribute[:alias] || attribute[:name]) : attribute[:name]
        type = attribute[:type]
        value = object.public_send(attribute[:name])
        if value != nil
          hash[key] = if is_class_kit?(type)
                        to_hash(value, use_alias)
                      elsif type == Array
                        value.map do |i|
                          if is_class_kit?(i.class)
                            to_hash(i, use_alias)
                          else
                            i
                          end
                        end
                      else
                        value
                      end
        end
      end
      @hash_helper.indifferent!(hash)
      hash
    end
This method is called to convert a ClassKit object into a Hash.