Method: Muster::Strategies::Pagination#parse_page

Defined in:
lib/muster/strategies/pagination.rb

#parse_page(parameters) ⇒ Fixnum (protected)

Returns the current page for the current query string.

If page is not specified, or is not a positive number, 1 will be returned instead.

Examples:


page = parse_page(:page => 2)    #=>  2
page = parse_page(:page => nil)  #=>  1

Parameters:

  • parameters (Hash)

    the parameters parsed from the query string

Returns:

  • (Fixnum)


83
84
85
86
87
# File 'lib/muster/strategies/pagination.rb', line 83

def parse_page(parameters)
  page = parameters.delete(:page).to_i
  page = 1 unless page > 0
  page
end