# frozen_string_literal: true <%- @types.each do |type| -%> require_relative '<%= @index_name.demodulize.underscore.to_s %>/collections/<%= type.underscore %>_collection' <%- end if @cli_options[:collections] && !@cli_options[:active_record] -%> <%- @types.each do |type| -%> require_relative '<%= @index_name.demodulize.underscore.to_s %>/serializers/<%= type.underscore %>_serializer' <%- end if @cli_options[:serializers] -%> class <%= @index_name %> < <%= @base_class %> <%- if @cli_options[:active_record] -%> plugin :active_record <%- end -%> <%- if @types.empty? -%> <%- if @cli_options[:active_record] -%> collection ::<%= @index_name.camelize %>.all <%- elsif @cli_options[:collections] -%> collection Collections::Collection <%- else -%> collection do |**context, &block| query = <%= @index_name.camelize.sub(/Index$/, '') %>.all query = query.where(id: context[:id]) if context[:id] query.find_in_batches(batch_size: 1_000) do |batch| block.call(batch) end end <%- end -%> <%- if @cli_options[:serializers] -%> serializer Serializers::Serializer <%- else -%> serializer do |object, **_context| { id: object.id, name: object.name, } end <%- end # if @cli_options[:serializers] -%> <%- end # /@types.empty?-%> <%- @types.each do |type| -%> repository :<%= type.underscore %> do <%- if @cli_options[:active_record] -%> collection ::<%= type.camelize %>.all <%- elsif @cli_options[:collections] -%> collection Collections::<%= type.camelize %>Collection <%- else -%> collection do |**context, &block| query = <%= type.camelize %>.all query = query.where(id: context[:id]) if context[:id] query.find_in_batches(batch_size: 1_000) do |batch| block.call(batch) end end <%- end -%> <%- if @cli_options[:serializers] -%> serializer Serializers::<%= type.camelize %>Serializer <%- else -%> serializer do |<%= type.underscore %>, **_context| { id: <%= type.underscore %>.id, name: <%= @index_name.underscore %>.name, } end <%- end -%> end <%- end #@types.each do |type| -%> end