Class: Wor::Paginate::Adapters::WillPaginateAlreadyPaginated

Inherits:
Base
  • Object
show all
Defined in:
lib/wor/paginate/adapters/will_paginate_already_paginated.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#adapt?, #initialize, #next_page, #previous_page

Constructor Details

This class inherits a constructor from Wor::Paginate::Adapters::Base

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



8
9
10
# File 'lib/wor/paginate/adapters/will_paginate_already_paginated.rb', line 8

def page
  @page
end

Instance Method Details

#countObject



22
23
24
# File 'lib/wor/paginate/adapters/will_paginate_already_paginated.rb', line 22

def count
  paginated_content.to_a.size
end

#paginated_contentObject



17
18
19
20
# File 'lib/wor/paginate/adapters/will_paginate_already_paginated.rb', line 17

def paginated_content
  @paginated_content ||= @content.limit(nil).offset(0)
                                 .paginate(page: @page, per_page: @limit)
end

#required_methodsObject



10
11
12
13
14
15
# File 'lib/wor/paginate/adapters/will_paginate_already_paginated.rb', line 10

def required_methods
  # Methods will_paginate adds to ActiveRecord relations:
  ### [:current_page, :total_entries, :total_entries=, :find_last, :current_page=,
  ### :scoped, :total_pages, :next_page, :previous_page, :out_of_bounds?]
  %i[previous_page out_of_bounds? total_entries= total_pages current_page=]
end

#total_countObject



26
27
28
# File 'lib/wor/paginate/adapters/will_paginate_already_paginated.rb', line 26

def total_count
  paginated_content.total_entries
end