Sha256: 29eb56d0cd360f6535e608ee5612ccc8d8cb209d5ace7f3827e143a40da01683

Contents?: true

Size: 569 Bytes

Versions: 1

Compression:

Stored size: 569 Bytes

Contents

# frozen_string_literal: true

require_relative './base_processor'
require_relative './paginate/enumerable_adapter'

class ActiveSet
  class PaginateProcessor < BaseProcessor
    def process
      return @set if @set.count < pagesize
      adapter.new(instruction).process(@set)
    end

    private

    def adapter
      EnumerableAdapter
    end

    def instruction
      Instructions::Entry.new(page_number, pagesize)
    end

    def page_number
      @instructions.get(:page) || 1
    end

    def pagesize
      @instructions.get(:size) || 25
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activeset-0.3.1 lib/active_set/processors/paginate_processor.rb