Sha256: f4c16768205e269c0ce86733d39aed9b6518bcc8642675aff5f39b0d372a3a79

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

require 'forwardable'
module Plucky
  module Pagination
    class Collection < Array
      extend Forwardable

      def_delegators  :@paginator,
                      :total_entries, :total_pages,
                      :current_page,  :per_page,
                      :previous_page, :next_page,
                      :skip,          :limit,
                      :offset,        :out_of_bounds?

      def initialize(records, paginator)
        replace records
        @paginator = paginator
      end

      def method_missing(method, *args)
        @paginator.send method, *args
      end

      # Public
      def paginator(p=nil)
        return @paginator if p.nil?
        @paginator = p
        self
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plucky-0.8.0 lib/plucky/pagination/collection.rb
plucky-0.7.0 lib/plucky/pagination/collection.rb