Sha256: c8628fff101d06985ccb2d565a69511b078766e5bf81b25d8045d45121c4f849

Contents?: true

Size: 782 Bytes

Versions: 30

Compression:

Stored size: 782 Bytes

Contents

require 'sequel'
require 'sequel/extensions/pagination'
require 'will_paginate/collection'

module WillPaginate
  # Sequel already supports pagination; we only need to make the
  # resulting dataset look a bit more like WillPaginate::Collection
  module SequelMethods
    include WillPaginate::CollectionMethods

    def total_pages
      page_count
    end

    def per_page
      page_size
    end

    def size
      current_page_record_count
    end
    alias length size

    def total_entries
      pagination_record_count
    end

    def out_of_bounds?
      current_page > total_pages
    end

    # Current offset of the paginated collection
    def offset
      (current_page - 1) * per_page
    end
  end

  Sequel::Dataset::Pagination.send(:include, SequelMethods)
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
will_paginate-4.0.1 lib/will_paginate/sequel.rb
will_paginate-4.0.0 lib/will_paginate/sequel.rb
will_paginate-3.3.1 lib/will_paginate/sequel.rb
will_paginate-3.3.0 lib/will_paginate/sequel.rb
will_paginate-3.2.1 lib/will_paginate/sequel.rb
will_paginate-3.2.0 lib/will_paginate/sequel.rb
will_paginate-3.1.8 lib/will_paginate/sequel.rb
will_paginate-3.1.7 lib/will_paginate/sequel.rb
will_paginate-3.1.6 lib/will_paginate/sequel.rb
will_paginate-3.0.12 lib/will_paginate/sequel.rb
will_paginate-3.1.5 lib/will_paginate/sequel.rb
will_paginate-3.0.11 lib/will_paginate/sequel.rb
will_paginate-3.1.3 lib/will_paginate/sequel.rb
will_paginate-3.0.10 lib/will_paginate/sequel.rb
will_paginate-3.0.9 lib/will_paginate/sequel.rb
will_paginate-3.1.2 lib/will_paginate/sequel.rb
will_paginate-3.1.1 lib/will_paginate/sequel.rb
will_paginate-3.0.8 lib/will_paginate/sequel.rb
will_paginate-3.1.0 lib/will_paginate/sequel.rb
will_paginate_seo-3.0.4 lib/will_paginate/sequel.rb