Class: Simple::SQL::Result
- Inherits:
-
Array
- Object
- Array
- Simple::SQL::Result
- Defined in:
- lib/simple/sql/result.rb,
lib/simple/sql/result.rb
Overview
The result of SQL.all
This class implements the basic interface of a Result set. Record result sets support the conversion of a record into a custom type of the callers choice, via the :into option for SQL.all
and SQL.ask
.
Direct Known Subclasses
Defined Under Namespace
Modules: AssociationLoader Classes: Records
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
returns the current page number in a paginated search.
-
#total_count ⇒ Object
readonly
returns the total_count of search hits.
-
#total_pages ⇒ Object
readonly
returns the total number of pages of search hits.
Class Method Summary collapse
-
.build(records, target_type:, pg_source_oid:) ⇒ Object
A Result object is requested via ::Simple::SQL::Result.build, which then chooses the correct implementation, based on the
target_type:
parameter.
Instance Method Summary collapse
-
#initialize(records) ⇒ Result
constructor
:nodoc:.
Constructor Details
#initialize(records) ⇒ Result
:nodoc:
30 31 32 |
# File 'lib/simple/sql/result.rb', line 30 def initialize(records) # :nodoc: replace(records) end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
returns the current page number in a paginated search
This is filled in when resolving a paginated scope.
48 49 50 |
# File 'lib/simple/sql/result.rb', line 48 def current_page @current_page end |
#total_count ⇒ Object (readonly)
returns the total_count of search hits
This is filled in when resolving a paginated scope.
37 38 39 |
# File 'lib/simple/sql/result.rb', line 37 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
returns the total number of pages of search hits
This is filled in when resolving a paginated scope. It takes into account the scope’s “per” option.
43 44 45 |
# File 'lib/simple/sql/result.rb', line 43 def total_pages @total_pages end |
Class Method Details
.build(records, target_type:, pg_source_oid:) ⇒ Object
A Result object is requested via ::Simple::SQL::Result.build, which then chooses the correct implementation, based on the target_type:
parameter.
22 23 24 25 26 27 28 |
# File 'lib/simple/sql/result.rb', line 22 def self.build(records, target_type:, pg_source_oid:) # :nodoc: if target_type.nil? new(records) else Records.new(records, target_type: target_type, pg_source_oid: pg_source_oid) end end |