Class: Skykick::RequestPagination::ODataPagination
- Inherits:
-
Object
- Object
- Skykick::RequestPagination::ODataPagination
- Defined in:
- lib/skykick/pagination.rb
Overview
Skykick uses Odata pagination but unfortunately does not support skipping pages. Using skip responds with “The query specified in the URI is not valid. Query option ‘Skip’ is not allowed. To allow it, set the ‘AllowedQueryOptions’ property on EnableQueryAttribute or QueryValidationSettings.”
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(page_size) ⇒ ODataPagination
constructor
A new instance of ODataPagination.
-
#more_pages? ⇒ Boolean
only single page available.
- #next_page!(data) ⇒ Object
- #page_options ⇒ Object
Constructor Details
#initialize(page_size) ⇒ ODataPagination
Returns a new instance of ODataPagination.
15 16 17 18 19 20 |
# File 'lib/skykick/pagination.rb', line 15 def initialize(page_size) @offset = 0 @limit = page_size # we always have a first page @total = @limit end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
14 15 16 |
# File 'lib/skykick/pagination.rb', line 14 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
14 15 16 |
# File 'lib/skykick/pagination.rb', line 14 def offset @offset end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
14 15 16 |
# File 'lib/skykick/pagination.rb', line 14 def total @total end |
Class Method Details
.data(body) ⇒ Object
35 36 37 |
# File 'lib/skykick/pagination.rb', line 35 def self.data(body) body end |
Instance Method Details
#more_pages? ⇒ Boolean
only single page available
39 40 41 |
# File 'lib/skykick/pagination.rb', line 39 def more_pages? @offset == 0 end |
#next_page!(data) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/skykick/pagination.rb', line 25 def next_page!(data) # assume array if data.count @total = data.count else @total = 1 end @offset += @limit end |
#page_options ⇒ Object
21 22 23 24 |
# File 'lib/skykick/pagination.rb', line 21 def { '$top': @limit, '$skip': @offset } { '$top': @limit } end |