Sha256: 09c2675fabf55bae04a6c7e27eeb0ba848f6e00d9e69bd5dc5e76f684f137094

Contents?: true

Size: 502 Bytes

Versions: 2

Compression:

Stored size: 502 Bytes

Contents

require 'will_mostly_paginate/collection'

Array.class_eval do
  def paginate(options = {})
    raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options

    WillPaginate::Collection.create(
        options[:page] || 1,
        options[:per_page] || 30,
        options[:total_entries] || self.length,
        options.keys.include?(:page_all) ? options[:page_all] : true
    ) { |pager|
      pager.replace self[pager.offset, pager.per_page].to_a
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
will_mostly_paginate-2.4.3 lib/will_mostly_paginate/array.rb
will_mostly_paginate-2.4.2 lib/will_mostly_paginate/array.rb