class Pagelux::QueryPaginator
Attributes
base_query[R]
Public Class Methods
new(base_query)
click to toggle source
# File lib/pagelux/query_paginator.rb, line 7 def initialize(base_query) @base_query = base_query end
Public Instance Methods
limit_query()
click to toggle source
# File lib/pagelux/query_paginator.rb, line 26 def limit_query base_query.offset((page-1) * limit).limit(limit) end
paginate(params)
click to toggle source
# File lib/pagelux/query_paginator.rb, line 11 def paginate(params) @pagination_data = PaginationData.new( params[:page], params[:limit], total ) limit_query end
query_total()
click to toggle source
# File lib/pagelux/query_paginator.rb, line 22 def query_total @query_total ||= base_query.count end
total()
click to toggle source
# File lib/pagelux/query_paginator.rb, line 18 def total query_total.is_a?(Hash) ? base_query.to_a.size : query_total end