Sha256: 35d541aa5ab31c206073d849f0819dcf094947a27e67bcb25d1dec6e35274a09

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

class <%= @index_name %> < <%= @base_class %>
  module Collections
    class <%= @type.camelize if @type %>Collection < Esse::Collection
      <%- if @type -%>
      # @yield [Array<<%= @type.camelize %>>]
      # @see <%= @index_name %>::<%= @type.camelize %>#collection
      <%- end -%>
      def each
        offset = 0
        while (rows = find_all(offset))
          break if rows.none?
          offset += 1
          yield(rows)
          # You may also preload associations here or add metadata useful for the serializer
          # yield(rows, **preload_associations(rows))
        end
      end

      protected

      # @param offset [Number] Offset to start from
      def find_all(offset)
        # @TODO load data from persistent store
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esse-0.2.2 lib/esse/cli/templates/collection.rb.erb