Class: PhlexKit::DataTableManualAdapter
- Inherits:
-
Object
- Object
- PhlexKit::DataTableManualAdapter
- Defined in:
- app/components/phlex_kit/data_table/data_table_manual_adapter.rb
Overview
Adapter for plain page/per_page/total_count pagination (no gem). Not a component — just the current_page/total_pages interface PhlexKit::DataTablePagination consumes. Ported from ruby_ui.
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#initialize(page:, per_page:, total_count:) ⇒ DataTableManualAdapter
constructor
A new instance of DataTableManualAdapter.
- #total_pages ⇒ Object
Constructor Details
#initialize(page:, per_page:, total_count:) ⇒ DataTableManualAdapter
Returns a new instance of DataTableManualAdapter.
8 9 10 11 12 |
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 8 def initialize(page:, per_page:, total_count:) @current_page = page.to_i @per_page = [ per_page.to_i, 1 ].max @total_count = total_count.to_i end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
6 7 8 |
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 6 def current_page @current_page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
6 7 8 |
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 6 def per_page @per_page end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
6 7 8 |
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 6 def total_count @total_count end |
Instance Method Details
#total_pages ⇒ Object
14 15 16 |
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 14 def total_pages [ (@total_count.to_f / @per_page).ceil, 1 ].max end |