Class: DataTables::Modules::Pagination
- Inherits:
-
Object
- Object
- DataTables::Modules::Pagination
- Defined in:
- lib/data_tables/modules/pagination.rb
Constant Summary collapse
- FIRST_PAGE =
1
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#filtered_scope ⇒ Object
readonly
Returns the value of attribute filtered_scope.
-
#original_scope ⇒ Object
readonly
Returns the value of attribute original_scope.
Instance Method Summary collapse
-
#initialize(original_scope, filtered_scope, request_parameters) ⇒ Pagination
constructor
A new instance of Pagination.
- #paginate ⇒ Object
Constructor Details
#initialize(original_scope, filtered_scope, request_parameters) ⇒ Pagination
Returns a new instance of Pagination.
10 11 12 13 14 |
# File 'lib/data_tables/modules/pagination.rb', line 10 def initialize(original_scope, filtered_scope, request_parameters) @original_scope = original_scope @filtered_scope = filtered_scope @request_parameters = request_parameters end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/data_tables/modules/pagination.rb', line 8 def context @context end |
#filtered_scope ⇒ Object (readonly)
Returns the value of attribute filtered_scope.
8 9 10 |
# File 'lib/data_tables/modules/pagination.rb', line 8 def filtered_scope @filtered_scope end |
#original_scope ⇒ Object (readonly)
Returns the value of attribute original_scope.
8 9 10 |
# File 'lib/data_tables/modules/pagination.rb', line 8 def original_scope @original_scope end |
Instance Method Details
#paginate ⇒ Object
16 17 18 19 20 21 |
# File 'lib/data_tables/modules/pagination.rb', line 16 def paginate start = (@request_parameters[:start] || '0').to_i length = (@request_parameters[:length] || '10').to_i page = (start / length) @filtered_scope = @filtered_scope.offset(page * length).limit(length) end |