Sha256: e26371f3addb74280fc1239366db9d32488e173efde71fdc11b79718740a621c

Contents?: true

Size: 404 Bytes

Versions: 2

Compression:

Stored size: 404 Bytes

Contents

module PaginatedTable
  class DataPage
    attr_reader :page, :data

    def initialize(collection, page)
      @page = page
      @data = collection.order(order_clause).paginate(pagination_params)
    end

    private

    def order_clause
      "#{@page.sort_column} #{@page.sort_direction}"
    end

    def pagination_params
      { :page => @page.number, :per_page => @page.rows }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paginated_table-0.0.9 lib/paginated_table/data_page.rb
paginated_table-0.0.8 lib/paginated_table/data_page.rb