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.
53 54 55 |
# File 'lib/simple/sql/scope.rb', line 53 def current_page @current_page end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
53 54 55 |
# File 'lib/simple/sql/scope.rb', line 53 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
53 54 55 |
# File 'lib/simple/sql/scope.rb', line 53 def total_pages @total_pages end |
Class Method Details
.attach(results, total_count:, per:, page:) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/simple/sql/scope.rb', line 55 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 |