Module: Simple::SQL::Scope::PageInfo
- Defined in:
- lib/simple/sql/scope.rb
Overview
The Scope::PageInfo module can be mixed into other objects to hold total_count, total_pages, and current_page.
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Class Method Summary collapse
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
110 111 112 |
# File 'lib/simple/sql/scope.rb', line 110 def current_page @current_page end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
110 111 112 |
# File 'lib/simple/sql/scope.rb', line 110 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
110 111 112 |
# File 'lib/simple/sql/scope.rb', line 110 def total_pages @total_pages end |
Class Method Details
.attach(results, total_count:, per:, page:) ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/simple/sql/scope.rb', line 112 def self.attach(results, total_count:, per:, page:) results.extend(self) results.instance_variable_set :@total_count, total_count results.instance_variable_set :@total_pages, (total_count + (per - 1)) / per results.instance_variable_set :@current_page, page results end |