Module: Workarea::Storefront::Pagination

Extended by:
ActiveSupport::Concern
Included in:
ProductBrowsing, SearchViewModel
Defined in:
app/view_models/workarea/storefront/pagination.rb

Instance Method Summary collapse

Instance Method Details

#first_page?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/view_models/workarea/storefront/pagination.rb', line 21

def first_page?
  page == 1
end

#last_page?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/view_models/workarea/storefront/pagination.rb', line 29

def last_page?
  page == total_pages
end

#next_pageObject



33
34
35
# File 'app/view_models/workarea/storefront/pagination.rb', line 33

def next_page
  page + 1 unless last_page?
end

#prev_pageObject



37
38
39
# File 'app/view_models/workarea/storefront/pagination.rb', line 37

def prev_page
  page - 1 unless first_page?
end

#search_queryObject

Raises:

  • (NotImplementedError)


10
11
12
13
14
15
# File 'app/view_models/workarea/storefront/pagination.rb', line 10

def search_query
  raise(
    NotImplementedError,
    "#{self.class} must implement #search_query for Pagination"
  )
end

#second_page?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/view_models/workarea/storefront/pagination.rb', line 25

def second_page?
  page == 2
end

#total_pagesObject



17
18
19
# File 'app/view_models/workarea/storefront/pagination.rb', line 17

def total_pages
  (total.to_f / per_page.to_f).ceil
end