Class: Filternator::Pagination
- Inherits:
-
Object
- Object
- Filternator::Pagination
- Defined in:
- lib/filternator/pagination.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(scope) ⇒ Pagination
constructor
A new instance of Pagination.
Constructor Details
#initialize(scope) ⇒ Pagination
Returns a new instance of Pagination.
6 7 8 |
# File 'lib/filternator/pagination.rb', line 6 def initialize(scope) @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/filternator/pagination.rb', line 4 def scope @scope end |
Instance Method Details
#as_json ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/filternator/pagination.rb', line 10 def as_json(*) { total: scope.total_entries, total_pages: scope.total_pages, first_page: scope.current_page == 1, last_page: scope.next_page.blank?, current_page: scope.current_page, previous_page: scope.previous_page, next_page: scope.next_page, out_of_bounds: scope.out_of_bounds?, offset: scope.offset } end |