class Ditty::Services::PaginationWrapper

Attributes

list[R]

Public Class Methods

new(list) click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 8
def initialize(list)
  @list = list
end

Public Instance Methods

current_page_record_range() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 72
def current_page_record_range
  if list.respond_to? :current_page_record_range
    list.current_page_record_range
  else
    return (0..0) if list.current_page > page_count

    a = 1 + (list.current_page - 1) * page_size
    b = a + page_size - 1
    b = pagination_record_count if b > pagination_record_count
    a..b
  end
end
first_page?() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 20
def first_page?
  if list.respond_to? :first_page?
    list.first_page?
  else
    list.previous_page.nil?
  end
end
last_page?() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 12
def last_page?
  if list.respond_to? :last_page?
    list.last_page?
  else
    list.next_page.nil?
  end
end
method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/ditty/services/pagination_wrapper.rb, line 60
def method_missing(method, *args)
  return super unless respond_to_missing?(method)

  list.send(method, *args)
end
page_count() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 36
def page_count
  if list.respond_to? :page_count
    list.page_count
  else
    list.total_pages
  end
end
page_size() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 44
def page_size
  if list.respond_to? :page_size
    list.page_size
  else
    list.per_page
  end
end
pagination_record_count() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 52
def pagination_record_count
  if list.respond_to? :pagination_record_count
    list.pagination_record_count
  else
    list.total_entries
  end
end
prev_page() click to toggle source
# File lib/ditty/services/pagination_wrapper.rb, line 28
def prev_page
  if list.respond_to? :prev_page
    list.prev_page
  else
    list.previous_page
  end
end
respond_to_missing?(method, _include_private = false) click to toggle source
Calls superclass method
# File lib/ditty/services/pagination_wrapper.rb, line 66
def respond_to_missing?(method, _include_private = false)
  return true if list.respond_to?(method)

  super
end