class Tapioca::Dsl::Compilers::ActiveRecordRelations

def create_relation_methods

def create_relation_methods
  create_relation_method("all")
  QUERY_METHODS.each do |method_name|
    case method_name
    when :where
      create_where_relation_method
    when :group
      create_relation_method(
        "group",
        parameters: [
          create_rest_param("args", type: "T.untyped"),
          create_block_param("blk", type: "T.untyped"),
        ],
        relation_return_type: RelationGroupChainClassName,
        association_return_type: AssociationRelationGroupChainClassName,
      )
    when :distinct
      create_relation_method(
        method_name.to_s,
        parameters: [create_opt_param("value", type: "T::Boolean", default: "true")],
      )
    when :extract_associated
      parameters = [create_param("association", type: "Symbol")]
      return_type = "T::Array[T.untyped]"
      relation_methods_module.create_method(
        method_name.to_s,
        parameters: parameters,
        return_type: return_type,
      )
      association_relation_methods_module.create_method(
        method_name.to_s,
        parameters: parameters,
        return_type: return_type,
      )
    when :select
      [relation_methods_module, association_relation_methods_module].each do |mod|
        mod.create_method(method_name.to_s) do |method|
          method.add_rest_param("args")
          method.add_block_param("blk")
          method.add_sig do |sig|
            sig.add_param("args", "T.untyped")
            sig.return_type = mod == relation_methods_module ? RelationClassName : AssociationRelationClassName
          end
          method.add_sig do |sig|
            sig.add_param("blk", "T.proc.params(record: #{constant_name}).returns(BasicObject)")
            sig.return_type = "T::Array[#{constant_name}]"
          end
        end
      end
    else
      create_relation_method(
        method_name,
        parameters: [
          create_rest_param("args", type: "T.untyped"),
          create_block_param("blk", type: "T.untyped"),
        ],
      )
    end
  end
end