Sha256: e7d906a2d84ae9eeada944722590aa3be3757fb28e89cc3da825a7572015cfca

Contents?: true

Size: 811 Bytes

Versions: 14

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

class <%= @index_name %> < <%= @base_class %>
  module Collections
    class <%= @repo.camelize if @repo %>Collection < Esse::Collection
      <%- if @repo -%>
      # @yield [Array<<%= @repo.camelize %>>]
      # @see <%= @index_name %>::<%= @repo.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 document
          # yield(rows, **preload_associations(rows))
        end
      end

      protected

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
esse-0.4.0.rc4 lib/esse/cli/templates/collection.rb.erb
esse-0.4.0.rc3 lib/esse/cli/templates/collection.rb.erb
esse-0.4.0.rc2 lib/esse/cli/templates/collection.rb.erb
esse-0.4.0.rc1 lib/esse/cli/templates/collection.rb.erb
esse-0.3.5 lib/esse/cli/templates/collection.rb.erb
esse-0.3.4 lib/esse/cli/templates/collection.rb.erb
esse-0.3.3 lib/esse/cli/templates/collection.rb.erb
esse-0.3.2 lib/esse/cli/templates/collection.rb.erb
esse-0.3.1 lib/esse/cli/templates/collection.rb.erb
esse-0.3.0 lib/esse/cli/templates/collection.rb.erb
esse-0.2.6 lib/esse/cli/templates/collection.rb.erb
esse-0.2.5 lib/esse/cli/templates/collection.rb.erb
esse-0.2.4 lib/esse/cli/templates/collection.rb.erb
esse-0.2.3 lib/esse/cli/templates/collection.rb.erb