Sha256: 88ce6190ba1961c8abaef52c64c6a6841ededf88a34a2202c39a3b1ec1743ea8

Contents?: true

Size: 568 Bytes

Versions: 7

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

require_relative '../base_adapter'
require_relative '../base_processor'

class ActiveSet
  class PaginateProcessor < BaseProcessor
    class EnumerableAdapter < BaseAdapter
      def process
        return return_set if @set.count < pagesize
        return_set(paginated_set)
      end

      private

      def paginated_set
        @set.each_slice(pagesize).take(page_number).last
      end

      def pagesize
        @instruction.value
      end

      def page_number
        @instruction.attribute.to_i
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activeset-0.5.1 lib/active_set/processors/paginate/enumerable_adapter.rb
activeset-0.5.0 lib/active_set/processors/paginate/enumerable_adapter.rb
activeset-0.4.4 lib/active_set/processors/paginate/enumerable_adapter.rb
activeset-0.4.3 lib/active_set/processors/paginate/enumerable_adapter.rb
activeset-0.4.2 lib/active_set/processors/paginate/enumerable_adapter.rb
activeset-0.4.1 lib/active_set/processors/paginate/enumerable_adapter.rb
activeset-0.4.0 lib/active_set/processors/paginate/enumerable_adapter.rb