Sha256: 2409f48c0fb5efa415b572192307c1c450e3e46d76d248c9fc86797fe9fcb360

Contents?: true

Size: 401 Bytes

Versions: 12

Compression:

Stored size: 401 Bytes

Contents

module BoundedContext
  module Paginable
    extend ActiveSupport::Concern

    included do
      def paginate(list)
        list = list.to_a
        page = params.fetch('page', 1).to_i
        page_size = params.fetch('size', 10).to_i
        offset = (page - 1) * page_size

        { total: list.size,
          page: page,
          elements: list[offset, page_size] }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
barkibu-kb-fake-0.27.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-0.27.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-fake-0.26.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-0.26.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-fake-0.25.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-0.25.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-fake-0.24.1 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-0.24.1 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-fake-0.24.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-0.24.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-fake-0.23.0 lib/kb/fake/bounded_context/paginable.rb
barkibu-kb-0.23.0 lib/kb/fake/bounded_context/paginable.rb