Sha256: e5d13cee63e02975dda8da77692cdd4104873898172fa7b91a0c6183150de4bf

Contents?: true

Size: 732 Bytes

Versions: 3

Compression:

Stored size: 732 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)
        @query.send method, *args
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plucky-0.6.6 lib/plucky/pagination/collection.rb
plucky-0.6.5 lib/plucky/pagination/collection.rb
plucky-0.6.4 lib/plucky/pagination/collection.rb