Sha256: c4369ab0c5f5c969eb500d27cefccde213ddd27030da6f16e52353a200cac7e2

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

module PaginatedTable
  class PageParams
    def self.create_page(request_params, defaults = {})
      params = request_params.reverse_merge(defaults)
      Page.new(
        :number => params[:page],
        :rows => params[:per_page],
        :sort_column => params[:sort_column],
        :sort_direction => params[:sort_direction]
      )
    end

    def self.to_params(page)
      {
        :page => page.number.to_s,
        :per_page => page.rows.to_s,
        :sort_column => page.sort_column,
        :sort_direction => page.sort_direction
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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